Don't process QR code if ScannerActivity is finished

This commit is contained in:
Alexander Bakker 2022-12-03 21:26:31 +01:00
parent 74ecdec637
commit 12683e3ff0

View file

@ -178,6 +178,10 @@ public class ScannerActivity extends AegisActivity implements QrCodeAnalyzer.Lis
@Override @Override
public void onQrCodeDetected(Result result) { public void onQrCodeDetected(Result result) {
new Handler(getMainLooper()).post(() -> { new Handler(getMainLooper()).post(() -> {
if (isFinishing()) {
return;
}
if (_analysis != null) { if (_analysis != null) {
try { try {
Uri uri = Uri.parse(result.getText().trim()); Uri uri = Uri.parse(result.getText().trim());
@ -190,6 +194,7 @@ public class ScannerActivity extends AegisActivity implements QrCodeAnalyzer.Lis
e.printStackTrace(); e.printStackTrace();
unbindPreview(_cameraProvider); unbindPreview(_cameraProvider);
Dialogs.showErrorDialog(this, Dialogs.showErrorDialog(this,
e.isPhoneFactor() ? R.string.read_qr_error_phonefactor : R.string.read_qr_error, e.isPhoneFactor() ? R.string.read_qr_error_phonefactor : R.string.read_qr_error,
e, ((dialog, which) -> bindPreview(_cameraProvider))); e, ((dialog, which) -> bindPreview(_cameraProvider)));