|
@@ -3,6 +3,7 @@ package com.develop.food.base.ui
|
|
import android.graphics.Color
|
|
import android.graphics.Color
|
|
import android.graphics.drawable.ColorDrawable
|
|
import android.graphics.drawable.ColorDrawable
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
|
|
+import android.view.KeyEvent
|
|
import android.view.LayoutInflater
|
|
import android.view.LayoutInflater
|
|
import android.view.View
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import android.view.ViewGroup
|
|
@@ -10,8 +11,9 @@ import android.view.Window
|
|
import android.view.WindowManager
|
|
import android.view.WindowManager
|
|
import androidx.fragment.app.DialogFragment
|
|
import androidx.fragment.app.DialogFragment
|
|
import androidx.fragment.app.FragmentManager
|
|
import androidx.fragment.app.FragmentManager
|
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
|
|
|
-abstract class FullScreenTransparentDialog: DialogFragment() {
|
|
|
|
|
|
+abstract class FullScreenTransparentDialog : DialogFragment() {
|
|
private var isShow = false
|
|
private var isShow = false
|
|
override fun onCreateView(
|
|
override fun onCreateView(
|
|
inflater: LayoutInflater,
|
|
inflater: LayoutInflater,
|
|
@@ -32,8 +34,17 @@ abstract class FullScreenTransparentDialog: DialogFragment() {
|
|
WindowManager.LayoutParams.MATCH_PARENT
|
|
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() {
|
|
fun removeSelf() {
|
|
if (isShow && isAdded) {
|
|
if (isShow && isAdded) {
|
|
isShow = false
|
|
isShow = false
|