mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Issue 1332: Multiple numeric dialogs appearing (#1356)
Co-authored-by: Jakub Kalinowski <kalj@netcompany.com>
This commit is contained in:
@@ -50,7 +50,6 @@ class NumberPickerFactory
|
|||||||
@Inject constructor(
|
@Inject constructor(
|
||||||
@ActivityContext private val context: Context
|
@ActivityContext private val context: Context
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
fun create(
|
fun create(
|
||||||
value: Double,
|
value: Double,
|
||||||
@@ -60,6 +59,8 @@ class NumberPickerFactory
|
|||||||
frequency: Frequency,
|
frequency: Frequency,
|
||||||
callback: ListHabitsBehavior.NumberPickerCallback
|
callback: ListHabitsBehavior.NumberPickerCallback
|
||||||
): AlertDialog {
|
): AlertDialog {
|
||||||
|
clearCurrentDialog()
|
||||||
|
|
||||||
val inflater = LayoutInflater.from(context)
|
val inflater = LayoutInflater.from(context)
|
||||||
val view = inflater.inflate(R.layout.number_picker_dialog, null)
|
val view = inflater.inflate(R.layout.number_picker_dialog, null)
|
||||||
|
|
||||||
@@ -113,6 +114,7 @@ class NumberPickerFactory
|
|||||||
}
|
}
|
||||||
.setOnDismissListener {
|
.setOnDismissListener {
|
||||||
callback.onNumberPickerDismissed()
|
callback.onNumberPickerDismissed()
|
||||||
|
currentDialog = null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frequency == DAILY) {
|
if (frequency == DAILY) {
|
||||||
@@ -153,6 +155,7 @@ class NumberPickerFactory
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentDialog = dialog
|
||||||
return dialog
|
return dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,6 +172,14 @@ class NumberPickerFactory
|
|||||||
val inputMethodManager = context.getSystemService(InputMethodManager::class.java)
|
val inputMethodManager = context.getSystemService(InputMethodManager::class.java)
|
||||||
inputMethodManager?.showSoftInput(v, 0)
|
inputMethodManager?.showSoftInput(v, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private var currentDialog: AlertDialog? = null
|
||||||
|
fun clearCurrentDialog() {
|
||||||
|
currentDialog?.dismiss()
|
||||||
|
currentDialog = null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SeparatorWatcherInputFilter(private val nextPicker: NumberPicker) : InputFilter {
|
class SeparatorWatcherInputFilter(private val nextPicker: NumberPicker) : InputFilter {
|
||||||
|
|||||||
Reference in New Issue
Block a user