From f59c854a1f572569e78f6ccd5e31f3084b2fdb32 Mon Sep 17 00:00:00 2001 From: jlduragos <141812510+jlduragos@users.noreply.github.com> Date: Mon, 30 Oct 2023 15:24:34 +0800 Subject: [PATCH] Fix MRZ landscape crashing by ignoring startCamera when viewFinder.display is null --- .../idpass/smartscanner/lib/SmartScannerActivity.kt | 1 + .../main/res/layout-land/activity_smart_scanner.xml | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/core-lib/src/main/java/org/idpass/smartscanner/lib/SmartScannerActivity.kt b/core-lib/src/main/java/org/idpass/smartscanner/lib/SmartScannerActivity.kt index 49d3c721..c0a2705c 100644 --- a/core-lib/src/main/java/org/idpass/smartscanner/lib/SmartScannerActivity.kt +++ b/core-lib/src/main/java/org/idpass/smartscanner/lib/SmartScannerActivity.kt @@ -412,6 +412,7 @@ class SmartScannerActivity : BaseActivity(), OnClickListener { @SuppressLint("ClickableViewAccessibility", "UnsafeOptInUsageError") private fun startCamera(analyzer: ImageAnalysis.Analyzer? = null, hasPDF417: Boolean = false) { viewFinder.post { + if (viewFinder.display == null) return@post this.getSystemService(Context.CAMERA_SERVICE) as CameraManager val cameraProviderFuture = ProcessCameraProvider.getInstance(this) cameraProviderFuture.addListener({ diff --git a/core-lib/src/main/res/layout-land/activity_smart_scanner.xml b/core-lib/src/main/res/layout-land/activity_smart_scanner.xml index 8d574a1a..2b4d9bda 100644 --- a/core-lib/src/main/res/layout-land/activity_smart_scanner.xml +++ b/core-lib/src/main/res/layout-land/activity_smart_scanner.xml @@ -98,6 +98,19 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + +