Prevent multiple error dialogs shows up at the same time
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
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
|
||||
@@ -13,12 +14,26 @@ 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, null)
|
||||
.setPositiveButton(android.R.string.ok, listener)
|
||||
}
|
||||
|
||||
fun Context.errorDialogBuilder(exception: Throwable): MaterialAlertDialogBuilder {
|
||||
return errorDialogBuilder(exception.localizedMessage ?: exception.toString())
|
||||
return errorDialogBuilder(exception, null)
|
||||
}
|
||||
|
||||
fun Context.errorDialogBuilder(
|
||||
exception: Throwable,
|
||||
listener: DialogInterface.OnClickListener?
|
||||
): MaterialAlertDialogBuilder {
|
||||
return errorDialogBuilder(exception.localizedMessage ?: exception.toString(), listener)
|
||||
}
|
||||
Reference in New Issue
Block a user