瀏覽代碼

fix: leak

tongmengxiao 1 月之前
父節點
當前提交
5d583682e2

+ 3 - 1
home/src/main/java/com/swago/home/MessageFragment.kt

@@ -112,7 +112,9 @@ class MessageFragment : BaseXFragment<FragmentMessageBinding>() {
     }
 
      fun setMessageSum(){
-         officialVm.getMsgSum()
+         if (isAdded){
+             officialVm.getMsgSum()
+         }
      }
 
     override fun onResume() {

+ 3 - 1
room/src/main/java/com/swago/room/manager/JoinRoomManager.kt

@@ -30,6 +30,7 @@ import com.swago.loadUrl
 import com.swago.room.R
 import de.hdodenhof.circleimageview.CircleImageView
 import java.io.File
+import java.lang.ref.WeakReference
 import java.net.URL
 import java.util.LinkedList
 
@@ -59,7 +60,8 @@ class JoinRoomManager : IRoomActiveListener {
 
     fun initViewStub(viewStub: ViewStub?, activity: FragmentActivity?) {
         mActivity = activity
-        svgParser = SVGAParser(mActivity)
+        val activityRef = WeakReference(mActivity)
+        svgParser = SVGAParser(activityRef.get())
         viewStub?.apply {
             val view = this.inflate()
             svgaImageView = view.findViewById(R.id.svgaImageView)

+ 3 - 1
room/src/main/java/com/swago/room/piaotiao/WaftView.kt

@@ -23,6 +23,7 @@ import com.swago.baseswago.util.SwagoInfo
 import com.swago.loadUrl
 import com.swago.room.R
 import com.swago.room.databinding.ViewWaftBinding
+import java.lang.ref.WeakReference
 import java.net.URL
 import java.util.*
 
@@ -45,7 +46,8 @@ class WaftView : FrameLayout {
 
     private fun initView(context: Context) {
         binding = ViewWaftBinding.inflate(LayoutInflater.from(context), this, true)
-        svgaParser = SVGAParser(context)
+        val activityRef = WeakReference(context)
+        svgaParser = SVGAParser(activityRef.get())
         this.context = context
     }
 

+ 0 - 1
room/src/main/java/com/swago/room/pk/PkVm.kt

@@ -97,7 +97,6 @@ class PkVm(application: Application) : AbsMsgVm(application) {
                             ipkListener.stopPK(stopPKModel)
                         }
                     }
-                    pkState?.invoke(false)
                 }
                 2 -> {
                     if (PKStateManager.roomState != PKStateManager.PK) {