Prechádzať zdrojové kódy

提交人:江天明
提交内容:优化

江天明 1 rok pred
rodič
commit
eb028d9c59

+ 0 - 1
BusinessStep/src/main/java/com/develop/step/modes/ModesDetailActivity.kt

@@ -1042,7 +1042,6 @@ class ModesDetailActivity : BaseActivity<ActivityModeDetailBinding>() {
      */
     override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
         Log.d("======","up")
-        hideDeviceStateDialog()
         if (modeType == ModesType.TURBO.name && event.keyCode == PRESS_DOWN_KEY_CODE) {
             //当前是turbo模式下,并且是物理键按下
             turboUpEvent()

+ 5 - 4
libBase/src/main/java/com/develop/food/base/ui/BaseActivity.kt

@@ -337,7 +337,7 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
                     if (event.confirm != null) {
                         event.confirm.callback();
                     }
-                    cancelConfirmDialog.removeSelf();
+                    deviceStateDialog.removeSelf();
                     lastMsg = "";
                 }
 
@@ -345,7 +345,7 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
                     if (event.cancel != null) {
                         event.cancel.callback();
                     }
-                    cancelConfirmDialog.removeSelf();
+                    deviceStateDialog.removeSelf();
                     lastMsg = "";
                 }
 
@@ -354,8 +354,9 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
     }
 
 
-    fun hideDeviceStateDialog() {
-        cancelConfirmDialog.removeSelf()
+    @Subscribe
+    fun closeEvent(event:FullScreenTransparentDialog.CloseDialogEvent){
+        deviceStateDialog.onConfirmClick()
     }
 
     open fun showDeviceStateDialog(): Boolean {

+ 12 - 1
libBase/src/main/java/com/develop/food/base/ui/FullScreenTransparentDialog.kt

@@ -3,6 +3,7 @@ package com.develop.food.base.ui
 import android.graphics.Color
 import android.graphics.drawable.ColorDrawable
 import android.os.Bundle
+import android.view.KeyEvent
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
@@ -10,8 +11,9 @@ import android.view.Window
 import android.view.WindowManager
 import androidx.fragment.app.DialogFragment
 import androidx.fragment.app.FragmentManager
+import org.greenrobot.eventbus.EventBus
 
-abstract class FullScreenTransparentDialog: DialogFragment() {
+abstract class FullScreenTransparentDialog : DialogFragment() {
     private var isShow = false
     override fun onCreateView(
         inflater: LayoutInflater,
@@ -32,8 +34,17 @@ abstract class FullScreenTransparentDialog: DialogFragment() {
                 WindowManager.LayoutParams.MATCH_PARENT
             )
         }
+        dialog?.setOnKeyListener { dialogInterface, i, keyEvent ->
+            if (keyEvent.action == KeyEvent.ACTION_UP) {
+                EventBus.getDefault().post(CloseDialogEvent())
+                false
+            } else keyEvent.action == KeyEvent.ACTION_DOWN
+        }
+
     }
 
+    class CloseDialogEvent {}
+
     fun removeSelf() {
         if (isShow && isAdded) {
             isShow = false

+ 3 - 3
libBase/src/main/java/com/develop/food/base/widgets/CancelConfirmDialog.kt

@@ -5,11 +5,8 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import android.widget.RelativeLayout
-import androidx.core.view.marginTop
-import com.develop.base.R
 import com.develop.base.databinding.DialogCancelConfirmBinding
 import com.develop.food.base.ui.FullScreenTransparentDialog
-import com.develop.food.base.utils.ResDimension
 
 class CancelConfirmDialog(
 ) : FullScreenTransparentDialog() {
@@ -66,6 +63,9 @@ class CancelConfirmDialog(
         return binding.root
     }
 
+    fun onConfirmClick(){
+        binding.tvYes.callOnClick()
+    }
 
     interface OnDialogClickListener {
         fun onConfirm()