diff --git a/app/src/main/java/io/nekohasekai/sfa/ktx/Dialogs.kt b/app/src/main/java/io/nekohasekai/sfa/ktx/Dialogs.kt index 5ff5b2a..80a9866 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ktx/Dialogs.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ktx/Dialogs.kt @@ -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()) } \ No newline at end of file diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/profile/QRScanActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/profile/QRScanActivity.kt index bc81a55..7d047e0 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/profile/QRScanActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/profile/QRScanActivity.kt @@ -62,8 +62,8 @@ class QRScanActivity : AbstractActivity() { } else { setResult(RESULT_CANCELED) finish() - } } + } private lateinit var imageAnalysis: ImageAnalysis private lateinit var imageAnalyzer: ImageAnalysis.Analyzer @@ -83,9 +83,6 @@ class QRScanActivity : AbstractActivity() { private lateinit var cameraPreview: Preview private lateinit var camera: Camera - // prevent multiple error dialogs shows up at the same time - private var invalidRawDataErrorDialogShowing: Boolean = false - private fun startCamera() { val cameraProviderFuture = try { ProcessCameraProvider.getInstance(this) @@ -132,14 +129,8 @@ class QRScanActivity : AbstractActivity() { importRemoteProfileFromString(value) return true } catch (e: Exception) { - if (invalidRawDataErrorDialogShowing) return false - - invalidRawDataErrorDialogShowing = true - lifecycleScope.launch { - errorDialogBuilder(e) { _, _ -> - invalidRawDataErrorDialogShowing = false - }.show() + errorDialogBuilder(e).show() } } return false