Browse Source

版本修改

wbspool 2 years ago
parent
commit
661a0c112c

+ 3 - 0
BusinessCommon/src/main/java/com/develop/common/ui/CommonBVMActivity.kt

@@ -25,4 +25,7 @@ abstract class CommonBVMActivity<VB : ViewBinding, VM : BaseViewModel> :
         super.onDestroy()
         lifecycle.removeObserver(viewModel)
     }
+
+
+
 }

+ 63 - 2
BusinessCommon/src/main/java/com/develop/common/ui/CommonBindingActivity.kt

@@ -25,6 +25,7 @@ import com.kuyuntech.cofarcooking.device.sdk.eventbus.event.DevPromptEvent
 import me.jessyan.autosize.AutoSizeCompat
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
+import com.develop.base.util.TopResumedAtyHolder
 
 /**
  * 带业务逻辑的基类
@@ -174,11 +175,71 @@ abstract class CommonBindingActivity<T : ViewBinding> : BaseBindingActivity<T>()
         screenSaverDialog.showDialog(supportFragmentManager, "cancelConfirmDialog")
     }
 
+//    @Subscribe
+//    fun onCookDevMsgEvent(event: DevPromptEvent) {
+//        if (isResume) {
+//            GlobalDevEvent.globalDevMsgEvent(event, supportFragmentManager, resources)
+//        }
+//    }
+
+    var lastMsg = ""
+
+    private val cancelConfirmDialog = CancelConfirmDialog()
+
+
     @Subscribe
     fun onCookDevMsgEvent(event: DevPromptEvent) {
-        if (isResume) {
-            GlobalDevEvent.globalDevMsgEvent(event, supportFragmentManager, resources)
+        if (!this.equals(TopResumedAtyHolder.getCurrentActivity())) {
+            return
         }
+
+        //            //已显示弹窗不重复显示
+//            if(FloatWindowManager.confirmCancelDialog.isAdded){
+//                return
+//            }
+        if (lastMsg == event.msg) {
+            return
+        }
+        lastMsg = event.msg
+        var confirmCancelDialog = CancelConfirmDialog()
+        confirmCancelDialog.showCancel = event.isShowCancelBtn
+        confirmCancelDialog.showConfirm = event.isShowConfirmBtn
+
+        confirmCancelDialog.cancelStr = resources.getString(
+            resources.getIdentifier(
+                event.cancelBtnText, "string", this.packageName
+            )
+        )
+        confirmCancelDialog.confirmStr = resources.getString(
+            resources.getIdentifier(
+                event.confirmButtonText, "string", this.packageName
+            )
+        )
+        confirmCancelDialog.title =
+            resources.getString(resources.getIdentifier(event.msg, "string", this.packageName))
+
+        confirmCancelDialog.showDialog(supportFragmentManager, "confirmCancelDialog")
+
+        confirmCancelDialog.onDialogClickListener =
+            object : CancelConfirmDialog.OnDialogClickListener {
+                override fun onConfirm() {
+                    if (event.confirm != null) {
+                        event.confirm.callback();
+                    }
+                    cancelConfirmDialog.removeSelf();
+                    lastMsg = "";
+                }
+
+                override fun onCancel() {
+                    if (event.confirm != null) {
+                        event.confirm.callback();
+                    }
+                    cancelConfirmDialog.removeSelf();
+                    lastMsg = "";
+                }
+
+            }
+
     }
 
     override fun getResources(): Resources {