|
@@ -1,6 +1,7 @@
|
|
package com.swago.home
|
|
package com.swago.home
|
|
|
|
|
|
import android.text.TextUtils
|
|
import android.text.TextUtils
|
|
|
|
+import android.view.View
|
|
import android.widget.Toast
|
|
import android.widget.Toast
|
|
import androidx.activity.viewModels
|
|
import androidx.activity.viewModels
|
|
import androidx.fragment.app.FragmentActivity
|
|
import androidx.fragment.app.FragmentActivity
|
|
@@ -22,6 +23,8 @@ import com.swago.baseswago.im.IMMessageManager
|
|
import com.swago.baseswago.inter.ApiManager
|
|
import com.swago.baseswago.inter.ApiManager
|
|
import com.swago.baseswago.libpay.IPayCallback
|
|
import com.swago.baseswago.libpay.IPayCallback
|
|
import com.swago.baseswago.libpay.PayManager
|
|
import com.swago.baseswago.libpay.PayManager
|
|
|
|
+import com.swago.baseswago.model.UnreadMessageVm
|
|
|
|
+import com.swago.baseswago.model.ViewModelProviderUtil
|
|
import com.swago.baseswago.model.pay.PayModel
|
|
import com.swago.baseswago.model.pay.PayModel
|
|
import com.swago.baseswago.util.*
|
|
import com.swago.baseswago.util.*
|
|
import com.swago.home.databinding.ActivityHomeBinding
|
|
import com.swago.home.databinding.ActivityHomeBinding
|
|
@@ -46,7 +49,7 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
|
|
private val officialVm by viewModels<OfficialVm>()
|
|
private val officialVm by viewModels<OfficialVm>()
|
|
private val homeVm by viewModels<HomeVm>()
|
|
private val homeVm by viewModels<HomeVm>()
|
|
private val payVm by viewModels<PayVm>()
|
|
private val payVm by viewModels<PayVm>()
|
|
- private val userVm by viewModels<UserVm>()
|
|
|
|
|
|
+ private lateinit var unreadMessageVm: UnreadMessageVm
|
|
|
|
|
|
private val listFragment =
|
|
private val listFragment =
|
|
arrayListOf(HomeFragment(), MessageFragment(), MineFragment())
|
|
arrayListOf(HomeFragment(), MessageFragment(), MineFragment())
|
|
@@ -56,6 +59,7 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
|
|
}
|
|
}
|
|
|
|
|
|
override fun initOther() {
|
|
override fun initOther() {
|
|
|
|
+ unreadMessageVm = ViewModelProviderUtil.getUnreadMessageViewModel(application)
|
|
TUIKit.init(this, UrlConstant.getImId(), TUIKitConfigs.getConfigs())
|
|
TUIKit.init(this, UrlConstant.getImId(), TUIKitConfigs.getConfigs())
|
|
PayManager.init()
|
|
PayManager.init()
|
|
IMMessageManager.groupMessageParser.add(GroupMsgParser())
|
|
IMMessageManager.groupMessageParser.add(GroupMsgParser())
|
|
@@ -117,6 +121,15 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
|
|
})
|
|
})
|
|
|
|
|
|
binding.viewPager.adapter = SwagoAdapter(listFragment, supportFragmentManager)
|
|
binding.viewPager.adapter = SwagoAdapter(listFragment, supportFragmentManager)
|
|
|
|
+ unreadMessageVm.unreadMessageData.observe(this){
|
|
|
|
+ if (it > 0){
|
|
|
|
+ binding.tvMessageNum.visibility = View.VISIBLE
|
|
|
|
+ binding.tvMessageNum.text = "$it"
|
|
|
|
+ } else {
|
|
|
|
+ binding.tvMessageNum.visibility = View.GONE
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -288,6 +301,9 @@ 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?) {
|