Jelajahi Sumber

fix: systemcount

tongmengxiao 3 bulan lalu
induk
melakukan
d79f5c2766

+ 1 - 2
app/src/main/java/com/swago/app/SplashActivity.kt

@@ -191,8 +191,7 @@ class SplashActivity : AppCompatActivity() {
 
     override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
         super.onActivityResult(requestCode, resultCode, data)
-        if (requestCode == 1001){
-            isRunning = false
+        if (resultCode == RESULT_OK && requestCode == 1001){
             splashVm.loginByAuto()
         }
     }

+ 1 - 0
baseswago/src/main/java/com/swago/baseswago/model/home/OfficialSumModel.kt

@@ -8,5 +8,6 @@ data class OfficialSumModel(
     val message_content:String,
     val unread_total:String,
     val message_time:String,
+    val userId:String,
     val unreadTotal:Long
 )

TEMPAT SAMPAH
baseswago/src/main/res/mipmap-xxhdpi/icon_living.png


+ 5 - 0
home/src/main/java/com/swago/home/HomeActivity.kt

@@ -138,11 +138,16 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
         conversationListener = object : V2TIMConversationListener(){
             override fun onTotalUnreadMessageCountChanged(totalUnreadCount: Long) {
                 super.onTotalUnreadMessageCountChanged(totalUnreadCount)
+                val systemCount = SpUtil.readString("systemCount")
+                if (!systemCount.isNullOrEmpty()){
+                    unreadMessageVm.systemMessage = systemCount.toLong()
+                }
                 unreadMessageVm.setTotalUnreadCount(totalUnreadCount)
             }
         }
         IMUtil.updateUnreadMessageCount(conversationListener!!)
         homeVm.systemMessageFun = {
+            SpUtil.putString("systemCount" , it.unreadTotal.toString())
             unreadMessageVm.setSystemUnreadCount(it.unreadTotal)
         }
     }

+ 5 - 1
home/src/main/java/com/swago/home/innerhome/HomeVm.kt

@@ -66,7 +66,11 @@ class HomeVm(application: Application) : BaseViewModel(application) {
             system_message
         ){
             it.data?.let {model ->
-                systemMessageFun?.invoke(model)
+                UserInfo.getUserInfo()?.let { userInfo ->
+                    if (model.userId == userInfo.id){
+                        systemMessageFun?.invoke(model)
+                    }
+                }
             }
         }
     }

+ 2 - 0
home/src/main/java/com/swago/home/official/OfficialMessageActivity.kt

@@ -13,6 +13,7 @@ import com.swago.baseswago.model.ViewModelProviderUtil
 import com.swago.baseswago.model.home.OfficialMsgModel
 import com.swago.baseswago.model.im.BindAnchorData
 import com.swago.baseswago.util.AppContext
+import com.swago.baseswago.util.SpUtil
 import com.swago.home.R
 import com.swago.home.databinding.ActivityOfficialMessageBinding
 
@@ -68,5 +69,6 @@ class OfficialMessageActivity : BaseListActivity<ActivityOfficialMessageBinding,
         }
         unreadMessageVm = ViewModelProviderUtil.getUnreadMessageViewModel(application)
         unreadMessageVm.setSystemUnreadCount(0)
+        SpUtil.putString("systemCount" , "0")
     }
 }