|
@@ -1,30 +1,28 @@
|
|
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
|
|
-import androidx.fragment.app.viewModels
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
import androidx.lifecycle.lifecycleScope
|
|
import androidx.viewpager.widget.ViewPager
|
|
import androidx.viewpager.widget.ViewPager
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.android.billingclient.api.Purchase
|
|
import com.android.billingclient.api.Purchase
|
|
-import com.google.gson.Gson
|
|
|
|
import com.swago.baseswago.PayVm
|
|
import com.swago.baseswago.PayVm
|
|
import com.swago.baseswago.SwagoAdapter
|
|
import com.swago.baseswago.SwagoAdapter
|
|
-import com.swago.baseswago.UserVm
|
|
|
|
import com.swago.baseswago.activity.BaseXActivity
|
|
import com.swago.baseswago.activity.BaseXActivity
|
|
import com.swago.baseswago.constant.ARouteConstant
|
|
import com.swago.baseswago.constant.ARouteConstant
|
|
import com.swago.baseswago.constant.UrlConstant
|
|
import com.swago.baseswago.constant.UrlConstant
|
|
import com.swago.baseswago.dialog.CloseAccountDialog
|
|
import com.swago.baseswago.dialog.CloseAccountDialog
|
|
-import com.swago.baseswago.dialog.ForceOfflineDialog
|
|
|
|
-import com.swago.baseswago.dialog.InviteBindingDialog
|
|
|
|
import com.swago.baseswago.dialog.OrderLostDialog
|
|
import com.swago.baseswago.dialog.OrderLostDialog
|
|
import com.swago.baseswago.im.GroupMsgParser
|
|
import com.swago.baseswago.im.GroupMsgParser
|
|
import com.swago.baseswago.im.IMMessageManager
|
|
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
|
|
@@ -49,6 +47,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 lateinit var unreadMessageVm: UnreadMessageVm
|
|
|
|
|
|
private val listFragment =
|
|
private val listFragment =
|
|
arrayListOf(HomeFragment(), MessageFragment(), MineFragment())
|
|
arrayListOf(HomeFragment(), MessageFragment(), MineFragment())
|
|
@@ -58,6 +57,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())
|
|
@@ -119,6 +119,16 @@ 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
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -271,6 +281,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?) {
|