Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1332: Multiple numeric dialogs appearing #1356

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class NumberPickerFactory
@Inject constructor(
@ActivityContext private val context: Context
) {

@SuppressLint("SetTextI18n")
fun create(
value: Double,
Expand All @@ -60,6 +59,8 @@ class NumberPickerFactory
frequency: Frequency,
callback: ListHabitsBehavior.NumberPickerCallback
): AlertDialog {
clearCurrentDialog()

val inflater = LayoutInflater.from(context)
val view = inflater.inflate(R.layout.number_picker_dialog, null)

Expand Down Expand Up @@ -113,6 +114,7 @@ class NumberPickerFactory
}
.setOnDismissListener {
callback.onNumberPickerDismissed()
currentDialog = null
}

if (frequency == DAILY) {
Expand Down Expand Up @@ -153,6 +155,7 @@ class NumberPickerFactory
false
}

currentDialog = dialog
return dialog
}

Expand All @@ -169,6 +172,14 @@ class NumberPickerFactory
val inputMethodManager = context.getSystemService(InputMethodManager::class.java)
inputMethodManager?.showSoftInput(v, 0)
}

companion object {
private var currentDialog: AlertDialog? = null
fun clearCurrentDialog() {
currentDialog?.dismiss()
currentDialog = null
}
}
}

class SeparatorWatcherInputFilter(private val nextPicker: NumberPicker) : InputFilter {
Expand Down