Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RvApp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lify
RvApp
Commits
0398b4d7
Commit
0398b4d7
authored
Oct 22, 2019
by
jianglx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加新消息,顶部弹出提示框的功能;添加客服在线的功能
parent
1bb09f67
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
559 additions
and
15 deletions
+559
-15
AndroidManifest.xml
RvClient/src/main/AndroidManifest.xml
+4
-0
MainActivity.java
RvClient/src/main/java/com/xxfc/rv/MainActivity.java
+35
-1
RvClientApplication.java
RvClient/src/main/java/com/xxfc/rv/RvClientApplication.java
+3
-0
RvActivityLifecycleCallbacks.java
.../java/com/xxfc/rv/other/RvActivityLifecycleCallbacks.java
+71
-0
BaseBean.java
...er/src/main/java/com/ruiwenliu/wrapper/base/BaseBean.java
+1
-1
Inc.java
...onent_utils/src/main/java/com/rv/component/utils/Inc.java
+1
-1
AndroidManifest.xml
plugin_im/src/main/AndroidManifest.xml
+2
-1
ChatActivity.java
plugin_im/src/main/java/com/rv/im/ChatActivity.java
+45
-2
ConversationListActivity.java
..._im/src/main/java/com/rv/im/ConversationListActivity.java
+1
-1
CustomerListActivity.java
plugin_im/src/main/java/com/rv/im/CustomerListActivity.java
+85
-5
CustomerListAdapter.java
.../src/main/java/com/rv/im/adapter/CustomerListAdapter.java
+18
-2
MessageTypeEnum.java
plugin_im/src/main/java/com/rv/im/enums/MessageTypeEnum.java
+2
-1
TitleTextWindow.java
plugin_im/src/main/java/com/rv/im/view/TitleTextWindow.java
+190
-0
shap_header_toast_background.xml
...im/src/main/res/drawable/shap_header_toast_background.xml
+14
-0
header_toast.xml
plugin_im/src/main/res/layout/header_toast.xml
+87
-0
No files found.
RvClient/src/main/AndroidManifest.xml
View file @
0398b4d7
...
@@ -85,6 +85,10 @@
...
@@ -85,6 +85,10 @@
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE"
/>
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE"
/>
<uses-permission
android:name=
"android.permission.REQUEST_INSTALL_PACKAGES"
/>
<uses-permission
android:name=
"android.permission.REQUEST_INSTALL_PACKAGES"
/>
<uses-permission
android:name=
"android.permission.SYSTEM_ALERT_WINDOW"
/>
<uses-permission
android:name=
"android.permission.SYSTEM_OVERLAY_WINDOW"
/>
<supports-screens
<supports-screens
android:anyDensity=
"true"
android:anyDensity=
"true"
android:largeScreens=
"true"
android:largeScreens=
"true"
...
...
RvClient/src/main/java/com/xxfc/rv/MainActivity.java
View file @
0398b4d7
package
com
.
xxfc
.
rv
;
package
com
.
xxfc
.
rv
;
import
android.app.AlertDialog
;
import
android.app.AlertDialog
;
import
android.app.Dialog
;
import
android.app.Notification
;
import
android.app.Notification
;
import
android.content.ComponentName
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Context
;
...
@@ -42,7 +43,6 @@ import com.ruiwenliu.wrapper.bean.UpdateTokenBean;
...
@@ -42,7 +43,6 @@ import com.ruiwenliu.wrapper.bean.UpdateTokenBean;
import
com.ruiwenliu.wrapper.receiver.NetWorkReceiver
;
import
com.ruiwenliu.wrapper.receiver.NetWorkReceiver
;
import
com.ruiwenliu.wrapper.statusbar.StatusBarUtil
;
import
com.ruiwenliu.wrapper.statusbar.StatusBarUtil
;
import
com.ruiwenliu.wrapper.util.UtilsManager
;
import
com.ruiwenliu.wrapper.util.UtilsManager
;
import
com.ruiwenliu.wrapper.util.glide.GlideApp
;
import
com.ruiwenliu.wrapper.util.listener.SwitchFragment
;
import
com.ruiwenliu.wrapper.util.listener.SwitchFragment
;
import
com.ruiwenliu.wrapper.weight.CustomScrollViewPager
;
import
com.ruiwenliu.wrapper.weight.CustomScrollViewPager
;
import
com.ruiwenliu.wrapper.weight.TitleView
;
import
com.ruiwenliu.wrapper.weight.TitleView
;
...
@@ -60,6 +60,7 @@ import com.rv.im.ImService;
...
@@ -60,6 +60,7 @@ import com.rv.im.ImService;
import
com.rv.im.ImSetting
;
import
com.rv.im.ImSetting
;
import
com.rv.im.call.AudioOrVideoController
;
import
com.rv.im.call.AudioOrVideoController
;
import
com.rv.im.db.table.ChatMessage
;
import
com.rv.im.db.table.ChatMessage
;
import
com.rv.im.view.TitleTextWindow
;
import
com.rv.im.xmpp.ListenerManager
;
import
com.rv.im.xmpp.ListenerManager
;
import
com.rv.im.xmpp.listener.ChatMessageListener
;
import
com.rv.im.xmpp.listener.ChatMessageListener
;
import
com.rv.rvmine.MineFragment
;
import
com.rv.rvmine.MineFragment
;
...
@@ -74,6 +75,7 @@ import com.rv.version.util.UpdateAppUtils;
...
@@ -74,6 +75,7 @@ import com.rv.version.util.UpdateAppUtils;
import
com.xxfc.discovery.DiscoveryFragment
;
import
com.xxfc.discovery.DiscoveryFragment
;
import
com.xxfc.discovery.api.DiscoveryApi
;
import
com.xxfc.discovery.api.DiscoveryApi
;
import
com.xxfc.discovery.bean.DiscoveryIMTokenBean
;
import
com.xxfc.discovery.bean.DiscoveryIMTokenBean
;
import
com.xxfc.rv.other.RvActivityLifecycleCallbacks
;
import
com.yuyife.okgo.OkGoUtil
;
import
com.yuyife.okgo.OkGoUtil
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.EventBus
;
...
@@ -162,6 +164,27 @@ public class MainActivity extends BaseActivity<CommonPresenter> implements DownL
...
@@ -162,6 +164,27 @@ public class MainActivity extends BaseActivity<CommonPresenter> implements DownL
EventBus
.
getDefault
().
register
(
this
);
EventBus
.
getDefault
().
register
(
this
);
DownListenerManager
.
getInstance
().
addDownListener
(
this
);
DownListenerManager
.
getInstance
().
addDownListener
(
this
);
ListenerManager
.
getInstance
().
addChatMessageListener
(
this
);
ListenerManager
.
getInstance
().
addChatMessageListener
(
this
);
checkOverlayPermission
();
}
/********
* 检查滴房车是否能在其他应用上层显示
*/
private
void
checkOverlayPermission
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
if
(!
Settings
.
canDrawOverlays
(
this
))
{
new
AlertDialog
.
Builder
(
this
).
setTitle
(
"提示"
)
.
setMessage
(
"滴房车正常运行需要在其他应用上层显示的权限"
)
.
setNegativeButton
(
"下次再说"
,
(
dialogInterface
,
i
)
->
{
dialogInterface
.
dismiss
();
}).
setPositiveButton
(
"好的"
,
(
dialogInterface
,
i
)
->
{
Intent
intent
=
new
Intent
(
Settings
.
ACTION_MANAGE_OVERLAY_PERMISSION
);
intent
.
setData
(
Uri
.
parse
(
"package:"
+
getPackageName
()));
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startActivity
(
intent
);
}).
setCancelable
(
false
).
show
();
}
}
}
}
...
@@ -715,6 +738,17 @@ public class MainActivity extends BaseActivity<CommonPresenter> implements DownL
...
@@ -715,6 +738,17 @@ public class MainActivity extends BaseActivity<CommonPresenter> implements DownL
@Override
@Override
public
void
onNewMessage
(
String
fromUserId
,
ChatMessage
message
,
boolean
isGroupMsg
)
{
public
void
onNewMessage
(
String
fromUserId
,
ChatMessage
message
,
boolean
isGroupMsg
)
{
boolean
canShow
=
true
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
canShow
=
false
;
if
(
Settings
.
canDrawOverlays
(
this
))
{
canShow
=
true
;
}
}
if
(
canShow
&&
(
RvActivityLifecycleCallbacks
.
isAppBackground
()
||
!
RvActivityLifecycleCallbacks
.
isAppInChatView
()))
{
TitleTextWindow
view
=
new
TitleTextWindow
(
this
);
view
.
show
();
}
((
HomeFragment
)
mAdapter
.
getItem
(
0
)).
newsComing
();
((
HomeFragment
)
mAdapter
.
getItem
(
0
)).
newsComing
();
((
TourismFragment
)
mAdapter
.
getItem
(
1
)).
newsComing
();
((
TourismFragment
)
mAdapter
.
getItem
(
1
)).
newsComing
();
}
}
...
...
RvClient/src/main/java/com/xxfc/rv/RvClientApplication.java
View file @
0398b4d7
...
@@ -31,6 +31,7 @@ import com.squareup.leakcanary.LeakCanary;
...
@@ -31,6 +31,7 @@ import com.squareup.leakcanary.LeakCanary;
import
com.tencent.bugly.crashreport.CrashReport
;
import
com.tencent.bugly.crashreport.CrashReport
;
import
com.umeng.commonsdk.UMConfigure
;
import
com.umeng.commonsdk.UMConfigure
;
import
com.umeng.socialize.PlatformConfig
;
import
com.umeng.socialize.PlatformConfig
;
import
com.xxfc.rv.other.RvActivityLifecycleCallbacks
;
import
com.yuyife.okgo.OkGoUtil
;
import
com.yuyife.okgo.OkGoUtil
;
import
java.util.Locale
;
import
java.util.Locale
;
...
@@ -125,6 +126,8 @@ public class RvClientApplication extends FrameApp {
...
@@ -125,6 +126,8 @@ public class RvClientApplication extends FrameApp {
}
}
LeakCanary.install(this);*/
LeakCanary.install(this);*/
/**********************************************/
/**********************************************/
registerActivityLifecycleCallbacks
(
new
RvActivityLifecycleCallbacks
());
}
}
...
...
RvClient/src/main/java/com/xxfc/rv/other/RvActivityLifecycleCallbacks.java
0 → 100644
View file @
0398b4d7
package
com
.
xxfc
.
rv
.
other
;
import
android.app.Activity
;
import
android.app.Application
;
import
android.os.Bundle
;
import
com.rv.im.CustomerListActivity
;
public
class
RvActivityLifecycleCallbacks
implements
Application
.
ActivityLifecycleCallbacks
{
private
static
int
ativiteCount
;
private
static
boolean
isInChatView
;
// app是否正在聊天模块
private
static
boolean
isSpecialCases
;
// 是否处于特殊情况,例如相机,图片选择
@Override
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
if
(
CustomerListActivity
.
class
.
getSimpleName
().
equals
(
activity
.
getClass
().
getSimpleName
()))
{
isInChatView
=
true
;
}
}
@Override
public
void
onActivityStarted
(
Activity
activity
)
{
}
@Override
public
void
onActivityResumed
(
Activity
activity
)
{
ativiteCount
+=
1
;
}
@Override
public
void
onActivityPaused
(
Activity
activity
)
{
ativiteCount
-=
1
;
}
@Override
public
void
onActivityStopped
(
Activity
activity
)
{
}
@Override
public
void
onActivitySaveInstanceState
(
Activity
activity
,
Bundle
outState
)
{
}
@Override
public
void
onActivityDestroyed
(
Activity
activity
)
{
if
(
CustomerListActivity
.
class
.
getSimpleName
().
equals
(
activity
.
getClass
().
getSimpleName
()))
{
isInChatView
=
false
;
}
}
public
static
boolean
isAppBackground
()
{
return
ativiteCount
==
0
?
true
:
false
&&
!
isSpecialCases
;
}
public
static
boolean
isAppInChatView
()
{
return
isInChatView
;
}
public
static
boolean
isIsSpecialCases
()
{
return
isSpecialCases
;
}
public
static
void
setIsSpecialCases
(
boolean
isSpecialCases
)
{
RvActivityLifecycleCallbacks
.
isSpecialCases
=
isSpecialCases
;
}
}
RvWrapper/src/main/java/com/ruiwenliu/wrapper/base/BaseBean.java
View file @
0398b4d7
component_utils/src/main/java/com/rv/component/utils/Inc.java
View file @
0398b4d7
This diff is collapsed.
Click to expand it.
plugin_im/src/main/AndroidManifest.xml
View file @
0398b4d7
...
@@ -34,7 +34,8 @@
...
@@ -34,7 +34,8 @@
<service
android:name=
"com.rv.im.call.RecordService"
/>
<service
android:name=
"com.rv.im.call.RecordService"
/>
<activity
android:name=
"com.rv.im.CustomerListActivity"
></activity>
<activity
android:name=
"com.rv.im.CustomerListActivity"
android:launchMode=
"singleTask"
></activity>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
plugin_im/src/main/java/com/rv/im/ChatActivity.java
View file @
0398b4d7
...
@@ -33,12 +33,16 @@ import com.ruiwenliu.wrapper.base.BaseStatusActivity;
...
@@ -33,12 +33,16 @@ import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import
com.ruiwenliu.wrapper.base.presenter.CommonPresenter
;
import
com.ruiwenliu.wrapper.base.presenter.CommonPresenter
;
import
com.ruiwenliu.wrapper.util.permission.RxPermission
;
import
com.ruiwenliu.wrapper.util.permission.RxPermission
;
import
com.ruiwenliu.wrapper.weight.TitleView
;
import
com.ruiwenliu.wrapper.weight.TitleView
;
import
com.rv.component.utils.CacheEnum
;
import
com.rv.component.utils.RvCache
;
import
com.rv.im.adapter.ChatContentAdapter
;
import
com.rv.im.adapter.ChatContentAdapter
;
import
com.rv.im.audio.IMRecordController
;
import
com.rv.im.audio.IMRecordController
;
import
com.rv.im.audio.RecordListener
;
import
com.rv.im.audio.RecordListener
;
import
com.rv.im.audio_x.VoicePlayer
;
import
com.rv.im.audio_x.VoicePlayer
;
import
com.rv.im.bean.User
;
import
com.rv.im.db.service.ChatMessageServiceImp
;
import
com.rv.im.db.service.ChatMessageServiceImp
;
import
com.rv.im.db.table.ChatMessage
;
import
com.rv.im.db.table.ChatMessage
;
import
com.rv.im.db.table.Customer
;
import
com.rv.im.enums.MessageStatusEnum
;
import
com.rv.im.enums.MessageStatusEnum
;
import
com.rv.im.enums.MessageTypeEnum
;
import
com.rv.im.enums.MessageTypeEnum
;
import
com.rv.im.mucfile.RvDownManager
;
import
com.rv.im.mucfile.RvDownManager
;
...
@@ -49,6 +53,7 @@ import com.rv.im.mvp.view.IChatView;
...
@@ -49,6 +53,7 @@ import com.rv.im.mvp.view.IChatView;
import
com.rv.im.photopicker.PhotoPickerActivity
;
import
com.rv.im.photopicker.PhotoPickerActivity
;
import
com.rv.im.util.FileUtils
;
import
com.rv.im.util.FileUtils
;
import
com.rv.im.util.InputManager
;
import
com.rv.im.util.InputManager
;
import
com.rv.im.util.RvImTimerTask
;
import
com.rv.im.video.ChatVideoPreviewActivity
;
import
com.rv.im.video.ChatVideoPreviewActivity
;
import
com.rv.im.view.ChatFaceView
;
import
com.rv.im.view.ChatFaceView
;
import
com.rv.im.xmpp.ListenerManager
;
import
com.rv.im.xmpp.ListenerManager
;
...
@@ -56,7 +61,10 @@ import com.rv.im.xmpp.listener.ChatMessageListener;
...
@@ -56,7 +61,10 @@ import com.rv.im.xmpp.listener.ChatMessageListener;
import
java.io.File
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Timer
;
import
pub.devrel.easypermissions.AppSettingsDialog
;
import
pub.devrel.easypermissions.AppSettingsDialog
;
...
@@ -82,6 +90,10 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
...
@@ -82,6 +90,10 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
private
String
targetUserId
;
private
String
targetUserId
;
private
String
targetName
;
private
String
targetName
;
private
int
customerStatus
;
private
Timer
timer
;
private
RvImTimerTask
timerTask
;
private
int
startPosition
;
private
int
startPosition
;
private
int
endPosition
;
private
int
endPosition
;
...
@@ -215,10 +227,11 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
...
@@ -215,10 +227,11 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
}
}
};
};
public
static
Intent
getIntent
(
Context
context
,
String
targetUserId
,
String
targetName
)
{
public
static
Intent
getIntent
(
Context
context
,
String
targetUserId
,
String
targetName
,
int
customerStatus
)
{
Intent
intent
=
new
Intent
(
context
,
ChatActivity
.
class
);
Intent
intent
=
new
Intent
(
context
,
ChatActivity
.
class
);
intent
.
putExtra
(
"targetUserId"
,
targetUserId
);
intent
.
putExtra
(
"targetUserId"
,
targetUserId
);
intent
.
putExtra
(
"targetName"
,
targetName
);
intent
.
putExtra
(
"targetName"
,
targetName
);
intent
.
putExtra
(
"customerStatus"
,
customerStatus
);
return
intent
;
return
intent
;
}
}
...
@@ -232,7 +245,9 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
...
@@ -232,7 +245,9 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
ListenerManager
.
getInstance
().
addChatMessageListener
(
this
);
ListenerManager
.
getInstance
().
addChatMessageListener
(
this
);
targetUserId
=
getIntent
().
getStringExtra
(
"targetUserId"
);
targetUserId
=
getIntent
().
getStringExtra
(
"targetUserId"
);
targetName
=
getIntent
().
getStringExtra
(
"targetName"
);
targetName
=
getIntent
().
getStringExtra
(
"targetName"
);
if
(!
TextUtils
.
isEmpty
(
targetName
))
titleView
.
setTitle
(
targetName
);
customerStatus
=
getIntent
().
getIntExtra
(
"customerStatus"
,
0
);
if
(!
TextUtils
.
isEmpty
(
targetName
))
titleView
.
setTitle
(
targetName
+
(
customerStatus
==
0
?
"(离线)"
:
"(在线)"
));
mInputManager
=
(
InputMethodManager
)
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
mInputManager
=
(
InputMethodManager
)
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
mLoginUserId
=
ImSetting
.
getUserId
();
mLoginUserId
=
ImSetting
.
getUserId
();
presenter
=
new
ChatPresenterImp
(
this
,
this
);
presenter
=
new
ChatPresenterImp
(
this
,
this
);
...
@@ -241,6 +256,10 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
...
@@ -241,6 +256,10 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
ChatMessageServiceImp
.
getInstance
(
getApplicationContext
()).
setMsgRead
(
targetUserId
);
ChatMessageServiceImp
.
getInstance
(
getApplicationContext
()).
setMsgRead
(
targetUserId
);
initWidget
();
initWidget
();
initListener
();
initListener
();
timer
=
new
Timer
();
timerTask
=
new
RvImTimerTask
(
timerListener
);
timer
.
schedule
(
timerTask
,
100
,
10000
);
}
}
@Override
@Override
...
@@ -258,6 +277,13 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
...
@@ -258,6 +277,13 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
@Override
@Override
public
void
onShowResult
(
int
requestType
,
BaseBean
result
)
{
public
void
onShowResult
(
int
requestType
,
BaseBean
result
)
{
if
(
requestType
==
1
)
{
User
user
=
(
User
)
result
;
if
(
user
!=
null
&&
user
.
getData
()
!=
null
)
{
if
(!
TextUtils
.
isEmpty
(
targetName
))
titleView
.
setTitle
(
targetName
+
(
user
.
getData
().
getOnlinestate
()
==
0
?
"(离线)"
:
"(在线)"
));
}
}
}
}
private
void
initWidget
()
{
private
void
initWidget
()
{
...
@@ -517,6 +543,10 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
...
@@ -517,6 +543,10 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
public
void
onDestroy
()
{
public
void
onDestroy
()
{
super
.
onDestroy
();
super
.
onDestroy
();
ListenerManager
.
getInstance
().
removeChatMessageListener
(
this
);
ListenerManager
.
getInstance
().
removeChatMessageListener
(
this
);
if
(
timer
!=
null
)
timer
.
cancel
();
if
(
timerTask
!=
null
)
timerTask
.
cancel
();
}
}
private
void
getData
()
{
private
void
getData
()
{
...
@@ -711,4 +741,17 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
...
@@ -711,4 +741,17 @@ public class ChatActivity extends BaseStatusActivity<CommonPresenter> implements
}
}
presenter
.
sendVoice
(
filePath
,
timeLen
);
presenter
.
sendVoice
(
filePath
,
timeLen
);
}
}
private
RvImTimerTask
.
TimerListener
timerListener
=
()
->
runOnUiThread
(()
->
{
AppConfig
appConfig
=
(
AppConfig
)
RvCache
.
getInstance
().
get
(
CacheEnum
.
IM_CONFIG
);
if
(
appConfig
!=
null
&&
!
TextUtils
.
isEmpty
(
appConfig
.
USER_GET_URL
))
initFriendState
(
appConfig
.
USER_GET_URL
);
});
private
void
initFriendState
(
String
url
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"access_token"
,
ImSetting
.
getImToken
());
params
.
put
(
"userId"
,
targetUserId
);
mPresenter
.
getData
(
1
,
url
,
User
.
class
,
params
,
false
);
}
}
}
plugin_im/src/main/java/com/rv/im/ConversationListActivity.java
View file @
0398b4d7
...
@@ -80,7 +80,7 @@ public class ConversationListActivity extends BaseStatusActivity<CommonPresenter
...
@@ -80,7 +80,7 @@ public class ConversationListActivity extends BaseStatusActivity<CommonPresenter
adapter
=
new
ChatConversationAdapter
(
conversations
);
adapter
=
new
ChatConversationAdapter
(
conversations
);
adapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
adapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
ChatConversation
conversation
=
conversations
.
get
(
position
);
ChatConversation
conversation
=
conversations
.
get
(
position
);
startActivityForResult
(
ChatActivity
.
getIntent
(
getApplicationContext
(),
conversation
.
getUserId
(),
conversation
.
getUserName
()),
1
);
startActivityForResult
(
ChatActivity
.
getIntent
(
getApplicationContext
(),
conversation
.
getUserId
(),
conversation
.
getUserName
()
,
0
),
1
);
});
});
recyclerView
.
setAdapter
(
adapter
);
recyclerView
.
setAdapter
(
adapter
);
...
...
plugin_im/src/main/java/com/rv/im/CustomerListActivity.java
View file @
0398b4d7
...
@@ -5,6 +5,7 @@ import android.os.Bundle;
...
@@ -5,6 +5,7 @@ import android.os.Bundle;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.text.TextUtils
;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -14,20 +15,29 @@ import com.ruiwenliu.wrapper.base.presenter.CommonPresenter;
...
@@ -14,20 +15,29 @@ import com.ruiwenliu.wrapper.base.presenter.CommonPresenter;
import
com.ruiwenliu.wrapper.weight.TitleView
;
import
com.ruiwenliu.wrapper.weight.TitleView
;
import
com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout
;
import
com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout
;
import
com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView
;
import
com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView
;
import
com.rv.component.utils.CacheEnum
;
import
com.rv.component.utils.RvCache
;
import
com.rv.im.adapter.CustomerListAdapter
;
import
com.rv.im.adapter.CustomerListAdapter
;
import
com.rv.im.bean.CustomersBean
;
import
com.rv.im.bean.CustomersBean
;
import
com.rv.im.bean.User
;
import
com.rv.im.db.service.ChatMessageServiceImp
;
import
com.rv.im.db.service.ChatMessageServiceImp
;
import
com.rv.im.db.service.CustomerServiceImp
;
import
com.rv.im.db.service.CustomerServiceImp
;
import
com.rv.im.db.service.ICustomerService
;
import
com.rv.im.db.service.ICustomerService
;
import
com.rv.im.db.table.ChatMessage
;
import
com.rv.im.db.table.ChatMessage
;
import
com.rv.im.db.table.Customer
;
import
com.rv.im.db.table.Customer
;
import
com.rv.im.util.RvImTimerTask
;
import
com.rv.im.util.ServiceUtils
;
import
com.rv.im.util.ServiceUtils
;
import
com.rv.im.xmpp.ListenerManager
;
import
com.rv.im.xmpp.ListenerManager
;
import
com.rv.im.xmpp.listener.ChatMessageListener
;
import
com.rv.im.xmpp.listener.ChatMessageListener
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Timer
;
import
okhttp3.Call
;
public
class
CustomerListActivity
extends
BaseStatusActivity
<
CommonPresenter
>
implements
SimpleRefreshLayout
.
OnSimpleRefreshListener
,
ChatMessageListener
{
public
class
CustomerListActivity
extends
BaseStatusActivity
<
CommonPresenter
>
implements
SimpleRefreshLayout
.
OnSimpleRefreshListener
,
ChatMessageListener
{
...
@@ -35,6 +45,10 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
...
@@ -35,6 +45,10 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
private
RecyclerView
recyclerView
;
private
RecyclerView
recyclerView
;
private
List
<
Customer
>
customers
=
new
ArrayList
<>();
private
List
<
Customer
>
customers
=
new
ArrayList
<>();
private
CustomerListAdapter
adapter
=
null
;
private
CustomerListAdapter
adapter
=
null
;
private
Timer
timer
;
private
RvImTimerTask
timerTask
;
private
Map
<
String
,
Integer
>
customerStatus
=
new
HashMap
<>();
private
int
testTime
=
0
;
private
int
testTime
=
0
;
...
@@ -43,12 +57,11 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
...
@@ -43,12 +57,11 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
return
R
.
layout
.
activity_customer_list
;
return
R
.
layout
.
activity_customer_list
;
}
}
@Override
@Override
protected
void
initView
(
Bundle
savedInstanceState
,
TitleView
titleView
,
Intent
intent
)
{
protected
void
initView
(
Bundle
savedInstanceState
,
TitleView
titleView
,
Intent
intent
)
{
ListenerManager
.
getInstance
().
addChatMessageListener
(
this
);
ListenerManager
.
getInstance
().
addChatMessageListener
(
this
);
titleView
.
setTitle
(
"客服列表"
);
titleView
.
setTitle
(
"客服列表"
);
timer
=
new
Timer
();
titleView
.
setImageResource
(
R
.
id
.
iv_title_right
,
R
.
drawable
.
ic_app_add
);
titleView
.
setImageResource
(
R
.
id
.
iv_title_right
,
R
.
drawable
.
ic_app_add
);
titleView
.
setChildClickListener
(
R
.
id
.
iv_title_right
,
v
->
{
titleView
.
setChildClickListener
(
R
.
id
.
iv_title_right
,
v
->
{
if
(!
BuildConfig
.
DEBUG
)
return
;
if
(!
BuildConfig
.
DEBUG
)
return
;
...
@@ -66,10 +79,11 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
...
@@ -66,10 +79,11 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
refreshLayout
=
findViewById
(
R
.
id
.
refresh
);
refreshLayout
=
findViewById
(
R
.
id
.
refresh
);
recyclerView
=
findViewById
(
R
.
id
.
recyclerView
);
recyclerView
=
findViewById
(
R
.
id
.
recyclerView
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
this
,
LinearLayout
.
VERTICAL
,
false
));
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
this
,
LinearLayout
.
VERTICAL
,
false
));
adapter
=
new
CustomerListAdapter
(
getApplicationContext
(),
customers
);
adapter
=
new
CustomerListAdapter
(
getApplicationContext
(),
customers
,
customerStatus
);
adapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
adapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
Customer
customer
=
customers
.
get
(
position
);
Customer
customer
=
customers
.
get
(
position
);
startActivityForResult
(
ChatActivity
.
getIntent
(
getApplicationContext
(),
customer
.
getImUserId
(),
customer
.
getName
()),
1
);
startActivityForResult
(
ChatActivity
.
getIntent
(
getApplicationContext
(),
customer
.
getImUserId
(),
customer
.
getName
(),
customerStatus
.
get
(
customer
.
getImUserId
())
==
null
?
0
:
customerStatus
.
get
(
customer
.
getImUserId
()).
intValue
()),
1
);
});
});
refreshLayout
.
setHeaderView
(
new
SimpleRefreshView
(
this
));
refreshLayout
.
setHeaderView
(
new
SimpleRefreshView
(
this
));
refreshLayout
.
setOnSimpleRefreshListener
(
this
);
refreshLayout
.
setOnSimpleRefreshListener
(
this
);
...
@@ -103,6 +117,10 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
...
@@ -103,6 +117,10 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
customers
.
clear
();
customers
.
clear
();
customers
.
addAll
(
lists
);
customers
.
addAll
(
lists
);
adapter
.
notifyDataSetChanged
();
adapter
.
notifyDataSetChanged
();
if
(
timerTask
==
null
)
{
timerTask
=
new
RvImTimerTask
(
timerListener
);
timer
.
schedule
(
timerTask
,
100
,
10000
);
}
}
else
{
}
else
{
mPresenter
.
getData
(
0
,
ImUrlConfig
.
HTTP_CUSTOMER_LIST_URL
,
CustomersBean
.
class
,
true
);
mPresenter
.
getData
(
0
,
ImUrlConfig
.
HTTP_CUSTOMER_LIST_URL
,
CustomersBean
.
class
,
true
);
}
}
...
@@ -122,8 +140,30 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
...
@@ -122,8 +140,30 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
customers
.
clear
();
customers
.
clear
();
customers
.
addAll
(
bean
.
getData
());
customers
.
addAll
(
bean
.
getData
());
adapter
.
notifyDataSetChanged
();
adapter
.
notifyDataSetChanged
();
if
(
timerTask
==
null
)
{
timerTask
=
new
RvImTimerTask
(
timerListener
);
timer
.
schedule
(
timerTask
,
100
,
10000
);
}
getCustomService
().
addCustomers
(
customers
);
getCustomService
().
addCustomers
(
customers
);
}
}
}
else
if
(
requestType
==
1
)
{
User
user
=
(
User
)
result
;
if
(
user
!=
null
&&
user
.
getData
()
!=
null
&&
customers
!=
null
)
{
int
position
=
0
;
if
(!
TextUtils
.
isEmpty
(
user
.
getData
().
getUserId
()))
{
customerStatus
.
remove
(
user
.
getData
().
getUserId
());
customerStatus
.
put
(
user
.
getData
().
getUserId
(),
user
.
getData
().
getOnlinestate
());
}
for
(
int
i
=
0
;
i
<
customers
.
size
();
i
++)
{
Customer
customer
=
customers
.
get
(
i
);
if
(!
TextUtils
.
isEmpty
(
user
.
getData
().
getUserId
())
&&
user
.
getData
().
getUserId
().
equals
(
customer
.
getImUserId
()))
{
position
=
i
;
break
;
}
}
adapter
.
notifyItemChanged
(
position
);
}
}
}
}
}
...
@@ -149,7 +189,25 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
...
@@ -149,7 +189,25 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
@Override
@Override
public
void
onNewMessage
(
String
fromUserId
,
ChatMessage
message
,
boolean
isGroupMsg
)
{
public
void
onNewMessage
(
String
fromUserId
,
ChatMessage
message
,
boolean
isGroupMsg
)
{
getCustomerList
();
if
(
customers
!=
null
&&
customers
.
size
()
>
0
)
{
for
(
Customer
customer
:
customers
)
{
if
(!
TextUtils
.
isEmpty
(
customer
.
getImUserId
())
&&
customer
.
getImUserId
().
equals
(
fromUserId
))
{
if
(
message
!=
null
)
customer
.
setLastMessageInfo
(
message
);
break
;
}
}
}
Collections
.
sort
(
customers
,
(
o1
,
o2
)
->
{
if
(
o1
.
getLastMsgTimes
()
>
o2
.
getLastMsgTimes
())
{
return
-
1
;
}
else
if
(
o1
.
getLastMsgTimes
()
==
o2
.
getLastMsgTimes
())
{
return
0
;
}
return
1
;
});
adapter
.
notifyDataSetChanged
();
}
}
@Override
@Override
...
@@ -164,5 +222,27 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
...
@@ -164,5 +222,27 @@ public class CustomerListActivity extends BaseStatusActivity<CommonPresenter> im
public
void
onDestroy
()
{
public
void
onDestroy
()
{
super
.
onDestroy
();
super
.
onDestroy
();
ListenerManager
.
getInstance
().
removeChatMessageListener
(
this
);
ListenerManager
.
getInstance
().
removeChatMessageListener
(
this
);
if
(
timer
!=
null
)
timer
.
cancel
();
if
(
timerTask
!=
null
)
timerTask
.
cancel
();
}
private
RvImTimerTask
.
TimerListener
timerListener
=
()
->
runOnUiThread
(()
->
{
AppConfig
appConfig
=
(
AppConfig
)
RvCache
.
getInstance
().
get
(
CacheEnum
.
IM_CONFIG
);
if
(
appConfig
!=
null
&&
!
TextUtils
.
isEmpty
(
appConfig
.
USER_GET_URL
))
if
(
customers
!=
null
&&
customers
.
size
()
>
0
)
for
(
Customer
customer
:
customers
)
{
if
(
customer
!=
null
)
initFriendState
(
appConfig
.
USER_GET_URL
,
customer
);
}
}
});
private
void
initFriendState
(
String
url
,
Customer
customer
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"access_token"
,
ImSetting
.
getImToken
());
params
.
put
(
"userId"
,
customer
.
getImUserId
());
mPresenter
.
getData
(
1
,
url
,
User
.
class
,
params
,
false
);
}
}
}
plugin_im/src/main/java/com/rv/im/adapter/CustomerListAdapter.java
View file @
0398b4d7
package
com
.
rv
.
im
.
adapter
;
package
com
.
rv
.
im
.
adapter
;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Color
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
...
@@ -11,24 +12,39 @@ import com.rv.im.db.table.Customer;
...
@@ -11,24 +12,39 @@ import com.rv.im.db.table.Customer;
import
com.rv.im.util.SmileyParser
;
import
com.rv.im.util.SmileyParser
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
public
class
CustomerListAdapter
extends
BaseQuickAdapter
<
Customer
,
BaseViewHolder
>
{
public
class
CustomerListAdapter
extends
BaseQuickAdapter
<
Customer
,
BaseViewHolder
>
{
private
SmileyParser
parser
;
private
SmileyParser
parser
;
public
CustomerListAdapter
(
Context
context
,
@Nullable
List
<
Customer
>
data
)
{
private
Map
<
String
,
Integer
>
customerStatus
;
public
CustomerListAdapter
(
Context
context
,
@Nullable
List
<
Customer
>
data
,
Map
<
String
,
Integer
>
map
)
{
super
(
R
.
layout
.
item_customer
,
data
);
super
(
R
.
layout
.
item_customer
,
data
);
this
.
parser
=
SmileyParser
.
getInstance
(
context
);
this
.
parser
=
SmileyParser
.
getInstance
(
context
);
this
.
customerStatus
=
map
;
}
}
@Override
@Override
protected
void
convert
(
BaseViewHolder
helper
,
Customer
item
)
{
protected
void
convert
(
BaseViewHolder
helper
,
Customer
item
)
{
if
(!
TextUtils
.
isEmpty
(
item
.
getName
()))
if
(!
TextUtils
.
isEmpty
(
item
.
getName
()))
helper
.
setText
(
R
.
id
.
tv_name
,
item
.
getName
());
helper
.
setText
(
R
.
id
.
tv_name
,
item
.
getName
());
if
(
customerStatus
.
get
(
item
.
getImUserId
())
!=
null
&&
customerStatus
.
get
(
item
.
getImUserId
())
==
1
)
{
helper
.
setText
(
R
.
id
.
tv_state
,
"在线"
);
helper
.
setText
(
R
.
id
.
tv_state
,
"在线"
);
helper
.
setTextColor
(
R
.
id
.
tv_state
,
Color
.
parseColor
(
"#FFB74B"
));
}
else
{
helper
.
setText
(
R
.
id
.
tv_state
,
"离线"
);
helper
.
setTextColor
(
R
.
id
.
tv_state
,
Color
.
parseColor
(
"#CCCCCC"
));
}
if
(!
TextUtils
.
isEmpty
(
item
.
getLastMsg
()))
if
(!
TextUtils
.
isEmpty
(
item
.
getLastMsg
()))
// helper.setText(R.id.tv_last_msg, item.getLastMsg());
// helper.setText(R.id.tv_last_msg, item.getLastMsg());
helper
.
setText
(
R
.
id
.
tv_last_msg
,
parser
.
addSmileySpans
(
deleteHtml
(
item
.
getLastMsg
()),
true
));
helper
.
setText
(
R
.
id
.
tv_last_msg
,
parser
.
addSmileySpans
(
deleteHtml
(
item
.
getLastMsg
()),
true
));
else
{
helper
.
setText
(
R
.
id
.
tv_last_msg
,
" "
);
}
}
}
private
static
String
deleteHtml
(
String
msg
)
{
private
static
String
deleteHtml
(
String
msg
)
{
...
...
plugin_im/src/main/java/com/rv/im/enums/MessageTypeEnum.java
View file @
0398b4d7
...
@@ -11,7 +11,8 @@ public enum MessageTypeEnum {
...
@@ -11,7 +11,8 @@ public enum MessageTypeEnum {
VOLTE_CALL
(
5
,
"语音通话"
),
VOLTE_CALL
(
5
,
"语音通话"
),
VIDEO_CALL
(
6
,
"视频通话"
),
VIDEO_CALL
(
6
,
"视频通话"
),
CANCEL
(
7
,
"撤销"
)
;
CANCEL
(
7
,
"撤销"
),
PING
(
8
,
"ping"
);
private
int
type
;
private
int
type
;
private
String
name
;
private
String
name
;
...
...
plugin_im/src/main/java/com/rv/im/view/TitleTextWindow.java
0 → 100644
View file @
0398b4d7
package
com
.
rv
.
im
.
view
;
import
android.animation.Animator
;
import
android.animation.AnimatorListenerAdapter
;
import
android.animation.ObjectAnimator
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Looper
;
import
android.os.Message
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
com.rv.im.CustomerListActivity
;
import
com.rv.im.R
;
public
class
TitleTextWindow
implements
View
.
OnTouchListener
{
private
Context
mContext
;
private
WindowManager
wm
;
private
LinearLayout
linearLayout
;
private
int
downY
;
public
TitleTextWindow
(
Context
context
)
{
mContext
=
context
;
}
private
android
.
os
.
Handler
mHander
=
new
android
.
os
.
Handler
(
Looper
.
myLooper
())
{
@Override
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
animDismiss
();
}
};
/**
* 动画,从顶部弹出
*/
private
void
animShow
()
{
//使用动画从顶部弹出
ObjectAnimator
animator
=
ObjectAnimator
.
ofFloat
(
linearLayout
,
"translationY"
,
-
linearLayout
.
getMeasuredHeight
(),
0
);
animator
.
setDuration
(
600
);
animator
.
start
();
}
/**
* 动画,从顶部收回
*/
private
void
animDismiss
()
{
if
(
linearLayout
==
null
||
linearLayout
.
getParent
()
==
null
)
{
return
;
}
ObjectAnimator
animator
=
ObjectAnimator
.
ofFloat
(
linearLayout
,
"translationY"
,
linearLayout
.
getTranslationY
(),
-
linearLayout
.
getMeasuredHeight
());
animator
.
setDuration
(
600
);
animator
.
start
();
animator
.
addListener
(
new
AnimatorListenerAdapter
()
{
@Override
public
void
onAnimationCancel
(
Animator
animation
)
{
super
.
onAnimationCancel
(
animation
);
}
@Override
public
void
onAnimationEnd
(
Animator
animation
)
{
super
.
onAnimationEnd
(
animation
);
//移除HeaderToast (一定要在动画结束的时候移除,不然下次进来的时候由于wm里边已经有控件了,所以会导致卡死)
if
(
null
!=
linearLayout
&&
null
!=
linearLayout
.
getParent
())
{
wm
.
removeView
(
linearLayout
);
}
}
@Override
public
void
onAnimationRepeat
(
Animator
animation
)
{
super
.
onAnimationRepeat
(
animation
);
}
@Override
public
void
onAnimationStart
(
Animator
animation
)
{
super
.
onAnimationStart
(
animation
);
}
@Override
public
void
onAnimationPause
(
Animator
animation
)
{
super
.
onAnimationPause
(
animation
);
}
@Override
public
void
onAnimationResume
(
Animator
animation
)
{
super
.
onAnimationResume
(
animation
);
}
});
}
/**
* 向外部暴露显示的方法
*/
public
void
show
()
{
createTitleView
();
animShow
();
//3S后自动关闭
mHander
.
sendEmptyMessageDelayed
(
20
,
1000
);
}
/**
* 向外部暴露关闭的方法
*/
public
void
dismiss
()
{
animDismiss
();
}
/**
* 视图创建方法
*/
private
void
createTitleView
()
{
//准备Window要添加的View
linearLayout
=
new
LinearLayout
(
mContext
);
final
LinearLayout
.
LayoutParams
layoutParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
linearLayout
.
setLayoutParams
(
layoutParams
);
View
titleView
=
View
.
inflate
(
mContext
,
R
.
layout
.
header_toast
,
null
);
//这里是你弹窗的UI
RelativeLayout
header
=
titleView
.
findViewById
(
R
.
id
.
header_toast
);
header
.
setOnClickListener
(
v
->
{
// Intent intent = new Intent();
// intent.setComponent(new ComponentName(mContext, mContext.getClass()));
// intent.putExtra("to", "chat");
// mContext.startActivity(intent);
Intent
intent
=
new
Intent
(
mContext
,
CustomerListActivity
.
class
);
mContext
.
startActivity
(
intent
);
animDismiss
();
});
// 为titleView设置Touch事件
linearLayout
.
setOnTouchListener
(
this
);
linearLayout
.
addView
(
titleView
);
// 定义WindowManager 并且将View添加到WindowManagar中去
wm
=
(
WindowManager
)
mContext
.
getSystemService
(
Context
.
WINDOW_SERVICE
);
WindowManager
.
LayoutParams
wm_params
=
new
WindowManager
.
LayoutParams
();
wm_params
.
flags
=
WindowManager
.
LayoutParams
.
FLAG_NOT_TOUCH_MODAL
|
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
|
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
|
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_IN_SCREEN
;
//这里需要注意,因为不同系统版本策略不一,所以需要根据版本判断设置type,否则会引起崩溃。
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
N_MR1
)
{
//大于android SDK 7.1.1
wm_params
.
type
=
WindowManager
.
LayoutParams
.
TYPE_APPLICATION_OVERLAY
;
}
else
{
wm_params
.
type
=
WindowManager
.
LayoutParams
.
TYPE_SYSTEM_ALERT
;
}
wm_params
.
gravity
=
Gravity
.
TOP
;
wm_params
.
x
=
0
;
wm_params
.
y
=
0
;
wm_params
.
format
=
-
3
;
// 会影响Toast中的布局消失的时候父控件和子控件消失的时机不一致,比如设置为-1之后就会不同步
wm_params
.
alpha
=
0.8f
;
linearLayout
.
measure
(
0
,
0
);
wm_params
.
height
=
linearLayout
.
getMeasuredHeight
();
wm
.
addView
(
linearLayout
,
wm_params
);
}
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
downY
=
(
int
)
event
.
getRawY
();
break
;
case
MotionEvent
.
ACTION_MOVE
:
int
moveY
=
(
int
)
event
.
getRawY
();
if
(
moveY
-
downY
<
0
)
{
//如果是向上滑动
linearLayout
.
setTranslationY
(
moveY
-
downY
);
}
break
;
case
MotionEvent
.
ACTION_UP
:
//达到一定比例后,松开手指将关闭弹窗
if
(
Math
.
abs
(
linearLayout
.
getTranslationY
())
>
linearLayout
.
getMeasuredHeight
()
/
1.5
)
{
Log
.
e
(
"TAG"
,
"回弹"
);
animDismiss
();
}
else
{
linearLayout
.
setTranslationY
(
0
);
}
break
;
default
:
break
;
}
return
true
;
}
}
\ No newline at end of file
plugin_im/src/main/res/drawable/shap_header_toast_background.xml
0 → 100644
View file @
0398b4d7
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<!-- 填充的颜色 -->
<solid
android:color=
"#FFFFFF"
/>
<corners
android:radius=
"5dp"
/>
<stroke
android:width=
"0.5dp"
android:color=
"#ebebeb"
/>
</shape>
\ No newline at end of file
plugin_im/src/main/res/layout/header_toast.xml
0 → 100644
View file @
0398b4d7
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/rl_rootview"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:padding=
"2dp"
>
<RelativeLayout
android:id=
"@+id/header_toast"
android:background=
"@drawable/shap_header_toast_background"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingBottom=
"5dp"
android:paddingLeft=
"20dp"
android:paddingRight=
"20sp"
android:paddingTop=
"5dp"
android:layout_marginTop=
"@dimen/dp20"
>
<RelativeLayout
android:id=
"@+id/header_toast_re"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<ImageView
android:src=
"@mipmap/logo"
android:id=
"@+id/header_toast_smallimg"
android:layout_width=
"20dp"
android:layout_height=
"20dp"
/>
<TextView
android:id=
"@+id/header_toast_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"5dp"
android:layout_toRightOf=
"@+id/header_toast_smallimg"
android:text=
"滴房车"
android:textColor=
"#797979"
android:textSize=
"10sp"
/>
<TextView
android:id=
"@+id/header_toast_time"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"5dp"
android:layout_toRightOf=
"@+id/header_toast_title"
android:text=
""
android:textColor=
"#999"
android:textSize=
"10sp"
/>
</RelativeLayout>
<TextView
android:id=
"@+id/header_toast_name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/header_toast_re"
android:layout_marginTop=
"5dp"
android:gravity=
"left"
android:text=
"您有新的消息"
android:textColor=
"#333"
android:textSize=
"15sp"
/>
<!--<ImageView-->
<!--android:id="@+id/header_toast_bigimg"-->
<!--android:layout_width="50dp"-->
<!--android:layout_height="50dp"-->
<!--android:layout_alignParentRight="true"-->
<!--android:layout_centerVertical="true"-->
<!--android:layout_marginLeft="12dp" />-->
<!--<TextView-->
<!--android:id="@+id/header_toast_content"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="1223333"-->
<!--android:layout_below="@+id/header_toast_name"-->
<!--android:layout_marginTop="5dp"-->
<!--android:textColor="#666"-->
<!--android:textSize="13sp" />-->
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment