Revert "Prevent multiple error dialogs shows up at the same time"

This reverts commit 7d2c4cdba3.
This commit is contained in:
世界
2024-10-25 22:28:38 +08:00
parent 45a1f5f0aa
commit 0de351375e
2 changed files with 4 additions and 28 deletions

View File

@@ -1,7 +1,6 @@
package io.nekohasekai.sfa.ktx
import android.content.Context
import android.content.DialogInterface
import androidx.annotation.StringRes
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import io.nekohasekai.sfa.R
@@ -14,26 +13,12 @@ fun Context.errorDialogBuilder(@StringRes messageId: Int): MaterialAlertDialogBu
}
fun Context.errorDialogBuilder(message: String): MaterialAlertDialogBuilder {
return errorDialogBuilder(message, null)
}
fun Context.errorDialogBuilder(
message: String,
listener: DialogInterface.OnClickListener?
): MaterialAlertDialogBuilder {
return MaterialAlertDialogBuilder(this)
.setTitle(R.string.error_title)
.setMessage(message)
.setPositiveButton(android.R.string.ok, listener)
.setPositiveButton(android.R.string.ok, null)
}
fun Context.errorDialogBuilder(exception: Throwable): MaterialAlertDialogBuilder {
return errorDialogBuilder(exception, null)
}
fun Context.errorDialogBuilder(
exception: Throwable,
listener: DialogInterface.OnClickListener?
): MaterialAlertDialogBuilder {
return errorDialogBuilder(exception.localizedMessage ?: exception.toString(), listener)
return errorDialogBuilder(exception.localizedMessage ?: exception.toString())
}