Reimplementing the multiple popups handling in the new popup solution.

pull/1457/head
Jakub Kalinowski 3 years ago
parent 0eae43fe55
commit 25a3509988

@ -73,6 +73,7 @@ class NumberPopup(
} }
fun show() { fun show() {
clearCurrentDialog()
dialog = Dialog(context, android.R.style.Theme_NoTitleBar) dialog = Dialog(context, android.R.style.Theme_NoTitleBar)
dialog.setContentView(view.root) dialog.setContentView(view.root)
dialog.window?.apply { dialog.window?.apply {
@ -84,6 +85,7 @@ class NumberPopup(
} }
dialog.setOnDismissListener { dialog.setOnDismissListener {
onDismiss() onDismiss()
currentDialog = null
} }
view.value.setOnKeyListener { _, keyCode, event -> view.value.setOnKeyListener { _, keyCode, event ->
@ -103,6 +105,7 @@ class NumberPopup(
view.value.requestFocusWithKeyboard() view.value.requestFocusWithKeyboard()
dialog.setCanceledOnTouchOutside(true) dialog.setCanceledOnTouchOutside(true)
dialog.dimBehind() dialog.dimBehind()
currentDialog = dialog
dialog.show() dialog.show()
} }
@ -112,4 +115,14 @@ class NumberPopup(
onToggle(value, notes) onToggle(value, notes)
dialog.dismiss() dialog.dismiss()
} }
companion object {
// Used to make sure that 2 popups aren't shown on top of each other
// If dialog that's already shown is detected, it's dismissed before the next one is opened.
private var currentDialog: Dialog? = null
fun clearCurrentDialog() {
currentDialog?.dismiss()
currentDialog = null
}
}
} }

Loading…
Cancel
Save