|
@@ -29,6 +29,7 @@ import com.swago.home.databinding.ActivityHomeBinding
|
|
import com.swago.home.innerhome.HomeVm
|
|
import com.swago.home.innerhome.HomeVm
|
|
import com.swago.home.official.OfficialVm
|
|
import com.swago.home.official.OfficialVm
|
|
import com.swago.home.update.UpdateDialog
|
|
import com.swago.home.update.UpdateDialog
|
|
|
|
+import com.tencent.imsdk.v2.V2TIMConversationListener
|
|
import com.tencent.qcloud.tim.uikit.TUIKit
|
|
import com.tencent.qcloud.tim.uikit.TUIKit
|
|
import com.tencent.qcloud.tim.uikit.base.IUIKitCallBack
|
|
import com.tencent.qcloud.tim.uikit.base.IUIKitCallBack
|
|
import com.tencent.qcloud.tim.uikit.config.TUIKitConfigs
|
|
import com.tencent.qcloud.tim.uikit.config.TUIKitConfigs
|
|
@@ -49,6 +50,7 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
|
|
private val payVm by viewModels<PayVm>()
|
|
private val payVm by viewModels<PayVm>()
|
|
private lateinit var unreadMessageVm: UnreadMessageVm
|
|
private lateinit var unreadMessageVm: UnreadMessageVm
|
|
private var messageFragment: MessageFragment? = null
|
|
private var messageFragment: MessageFragment? = null
|
|
|
|
+ private var conversationListener: V2TIMConversationListener?=null
|
|
|
|
|
|
private val listFragment =
|
|
private val listFragment =
|
|
arrayListOf(HomeFragment(), MessageFragment(), MineFragment())
|
|
arrayListOf(HomeFragment(), MessageFragment(), MineFragment())
|
|
@@ -131,7 +133,16 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ conversationListener = object : V2TIMConversationListener(){
|
|
|
|
+ override fun onTotalUnreadMessageCountChanged(totalUnreadCount: Long) {
|
|
|
|
+ super.onTotalUnreadMessageCountChanged(totalUnreadCount)
|
|
|
|
+ unreadMessageVm.setTotalUnreadCount(totalUnreadCount)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ IMUtil.updateUnreadMessageCount(conversationListener!!)
|
|
|
|
+ homeVm.systemMessageFun = {
|
|
|
|
+ unreadMessageVm.setSystemUnreadCount(it.unreadTotal)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -284,9 +295,6 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
|
|
IUIKitCallBack {
|
|
IUIKitCallBack {
|
|
override fun onSuccess(data: Any?) {
|
|
override fun onSuccess(data: Any?) {
|
|
IMUtil.joinGroup(null)
|
|
IMUtil.joinGroup(null)
|
|
- IMUtil.updateUnreadMessageCount {unread->
|
|
|
|
- unreadMessageVm.setTotalUnreadCount(unread)
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override fun onError(module: String?, errCode: Int, errMsg: String?) {
|
|
override fun onError(module: String?, errCode: Int, errMsg: String?) {
|
|
@@ -300,4 +308,11 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ override fun onDestroy() {
|
|
|
|
+ super.onDestroy()
|
|
|
|
+ if (conversationListener != null) {
|
|
|
|
+ IMUtil.removeConversationListener(conversationListener!!)
|
|
|
|
+ conversationListener = null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|