|
@@ -11,6 +11,7 @@ import com.shanp.youqi.common.vo.im.ConversationListVo
|
|
|
import com.shanp.youqi.common.widget.EmptyView
|
|
|
import com.shanp.youqi.core.event.IMReadMsgEvent
|
|
|
import com.shanp.youqi.core.event.IMReceivedMessageEvent
|
|
|
+import com.shanp.youqi.core.event.IMSendMessageEvent
|
|
|
import com.shanp.youqi.core.memory.AppManager
|
|
|
import com.shanp.youqi.im.R
|
|
|
import com.shanp.youqi.im.adapter.MessageListOnlyUserAdapter
|
|
@@ -18,6 +19,7 @@ import com.shanp.youqi.im.databinding.ImFragmentMessageListOnlyUserBinding
|
|
|
import com.shanp.youqi.im.dialog.MessageListDialog
|
|
|
import io.rong.imlib.RongIMClient
|
|
|
import io.rong.imlib.model.Conversation
|
|
|
+import io.rong.imlib.model.Message
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
import kotlinx.coroutines.launch
|
|
@@ -45,7 +47,7 @@ class MessageListOnlyUserFragment : UChatFragment() {
|
|
|
override fun initEventAndData(view: View) {
|
|
|
binding = ImFragmentMessageListOnlyUserBinding.bind(view)
|
|
|
initTitleBar(view).apply {
|
|
|
- titleView.textSize = 17f
|
|
|
+ titleView.textSize = 17f
|
|
|
}
|
|
|
initRecyclerView()
|
|
|
initListener()
|
|
@@ -75,19 +77,18 @@ class MessageListOnlyUserFragment : UChatFragment() {
|
|
|
override fun onReceive(event: IMReceivedMessageEvent) {
|
|
|
if (!AppManager.get().isConnectRongCloud) return
|
|
|
event.message?.let {
|
|
|
- val conversationType = it.conversationType
|
|
|
- if (conversationType == Conversation.ConversationType.PRIVATE) {
|
|
|
-
|
|
|
- GlobalScope.launch {
|
|
|
- withContext(Dispatchers.IO) {
|
|
|
- disposePrivateType(it.targetId)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ disposeMessage(it)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ register(RxBus.get().toFlowable(IMSendMessageEvent::class.java), object : EventSubscriber<IMSendMessageEvent>() {
|
|
|
+ override fun onReceive(event: IMSendMessageEvent) {
|
|
|
+ super.onReceive(event)
|
|
|
+ event.message?.let { disposeMessage(it) }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
binding.srl.setOnLoadMoreListener {
|
|
|
GlobalScope.launch(Dispatchers.Main) {
|
|
|
withContext(Dispatchers.IO) {
|
|
@@ -101,7 +102,7 @@ class MessageListOnlyUserFragment : UChatFragment() {
|
|
|
it.unreadMessageCount = 0
|
|
|
adapter.notifyItemChanged(position, MessageListOnlyUserAdapter.REFRESH_UNREAD_COUNT)
|
|
|
clearMessagesUnreadStatus(it.conversationType, it.targetId)
|
|
|
- messageListDialog.addConversation(it.targetId,it.senderUserName,it.portraitUrl)
|
|
|
+ messageListDialog.addConversation(it.targetId, it.senderUserName, it.portraitUrl)
|
|
|
// val conversationDialog = ConversationDialog()
|
|
|
// conversationDialog.targetId = it.targetId
|
|
|
// conversationDialog.targetUserName = it.senderUserName
|
|
@@ -118,6 +119,16 @@ class MessageListOnlyUserFragment : UChatFragment() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun disposeMessage(message: Message) {
|
|
|
+ if (message.conversationType == Conversation.ConversationType.PRIVATE) {
|
|
|
+ GlobalScope.launch {
|
|
|
+ withContext(Dispatchers.IO) {
|
|
|
+ disposePrivateType(message.targetId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private fun loadPrivateConversation() {
|
|
|
RongIMClient.getInstance().getConversationListByPage(loadPrivateConversation, timeStamp, count, Conversation.ConversationType.PRIVATE)
|
|
|
}
|