|
@@ -31,6 +31,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
|
|
@@ -51,6 +52,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())
|
|
@@ -61,7 +63,7 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
|
|
|
|
|
|
override fun initOther() {
|
|
override fun initOther() {
|
|
unreadMessageVm = ViewModelProviderUtil.getUnreadMessageViewModel(application)
|
|
unreadMessageVm = ViewModelProviderUtil.getUnreadMessageViewModel(application)
|
|
- TUIKit.init(this, UrlConstant.getImId(), TUIKitConfigs.getConfigs())
|
|
|
|
|
|
+ TUIKit.init(application, UrlConstant.getImId(), TUIKitConfigs.getConfigs())
|
|
PayManager.init()
|
|
PayManager.init()
|
|
IMMessageManager.groupMessageParser.add(GroupMsgParser())
|
|
IMMessageManager.groupMessageParser.add(GroupMsgParser())
|
|
SpUtil.putInt("isHomeBack" , 1)
|
|
SpUtil.putInt("isHomeBack" , 1)
|
|
@@ -133,6 +135,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)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -304,9 +316,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?) {
|
|
@@ -320,4 +329,12 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ override fun onDestroy() {
|
|
|
|
+ super.onDestroy()
|
|
|
|
+ if (conversationListener != null) {
|
|
|
|
+ IMUtil.removeConversationListener(conversationListener!!)
|
|
|
|
+ conversationListener = null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|