From 10bcb94bd4aa85ed82fe5041d7772114c1f5c5e8 Mon Sep 17 00:00:00 2001 From: Levin Li Date: Sat, 20 Feb 2021 16:00:36 +0800 Subject: [PATCH] Dismiss choice dialog when selected --- .../main/java/space/celestia/mobilecelestia/utils/Dialog.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/space/celestia/mobilecelestia/utils/Dialog.kt b/app/src/main/java/space/celestia/mobilecelestia/utils/Dialog.kt index e9102b0b..a89de270 100644 --- a/app/src/main/java/space/celestia/mobilecelestia/utils/Dialog.kt +++ b/app/src/main/java/space/celestia/mobilecelestia/utils/Dialog.kt @@ -70,8 +70,9 @@ fun Activity.showDateInput(title: String, format: String, handler: (Date?) -> Un fun Activity.showSingleSelection(title: String, selections: List, checkedIndex: Int, handler: (Int) -> Unit) { val builder = AlertDialog.Builder(this) builder.setTitle(title) - builder.setSingleChoiceItems(selections.toTypedArray(), checkedIndex) { _, index -> + builder.setSingleChoiceItems(selections.toTypedArray(), checkedIndex) { dialog, index -> handler(index) + dialog.dismiss() } builder.show()