Skip to content

Commit

Permalink
Fix : Multiple instance of dialog shown
Browse files Browse the repository at this point in the history
  • Loading branch information
neeldoshii committed Feb 26, 2024
1 parent 41ad51d commit 0185166
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CardBrowserMySearchesDialog : AnalyticsDialogFragment() {
@SuppressLint("CheckResult")
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
super.onCreate(savedInstanceState)
val alertDialog = AlertDialog.Builder(requireActivity())
val dialog = AlertDialog.Builder(requireActivity())
val type = requireArguments().getInt("type")
if (type == CARD_BROWSER_MY_SEARCHES_TYPE_LIST) {
savedFilters = requireArguments().getSerializableCompat("savedFilters")
Expand All @@ -56,23 +56,25 @@ class CardBrowserMySearchesDialog : AnalyticsDialogFragment() {
}
).apply {
notifyAdapterDataSetChanged() // so the values are sorted.
alertDialog.title(text = resources.getString(R.string.card_browser_list_my_searches_title))
dialog.title(text = resources.getString(R.string.card_browser_list_my_searches_title))
.customListAdapterWithDecoration(this, requireActivity())
}
} else if (type == CARD_BROWSER_MY_SEARCHES_TYPE_SAVE) {
val currentSearchTerms = requireArguments().getString("currentSearchTerms")
AlertDialog.Builder(requireActivity()).show {
return dialog.show {
title(text = getString(R.string.card_browser_list_my_searches_save))
positiveButton(android.R.string.ok)
negativeButton(R.string.dialog_cancel)
setView(R.layout.dialog_generic_text_input)
}.input(hint = getString(R.string.card_browser_list_my_searches_new_name), allowEmpty = false, displayKeyboard = true, waitForPositiveButton = true) { dialog, text ->
Timber.d("Saving search with title/terms: %s/%s", text, currentSearchTerms)
mySearchesDialogListener?.onSaveSearch(text.toString(), currentSearchTerms)
dialog.dismiss()
}.apply {
input(hint = getString(R.string.card_browser_list_my_searches_new_name), allowEmpty = false, displayKeyboard = true, waitForPositiveButton = true) { dialog, text ->
Timber.d("Saving search with title/terms: %s/%s", text, currentSearchTerms)
mySearchesDialogListener?.onSaveSearch(text.toString(), currentSearchTerms)
dialog.dismiss()
}
}
}
return alertDialog.show()
return dialog.create()
}

private fun removeSearch(searchName: String) {
Expand Down

0 comments on commit 0185166

Please sign in to comment.