Aperture: Make sure we only create single QrImageAnalyzer instance
Change-Id: I786f73ed80ec4af573267abb745294ecb264a71d
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 094218f..847e485 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -100,6 +100,8 @@
private val keyguardManager by lazy { getSystemService(KeyguardManager::class.java) }
private val locationManager by lazy { getSystemService(LocationManager::class.java) }
+ private val imageAnalyzer by lazy { QrImageAnalyzer(this) }
+
private lateinit var cameraProvider: ProcessCameraProvider
private lateinit var extensionsManager: ExtensionsManager
@@ -542,7 +544,7 @@
val cameraUseCases = when (cameraMode) {
CameraMode.QR -> {
cameraController.imageAnalysisTargetSize = outputSize
- cameraController.setImageAnalysisAnalyzer(cameraExecutor, QrImageAnalyzer(this))
+ cameraController.setImageAnalysisAnalyzer(cameraExecutor, imageAnalyzer)
CameraController.IMAGE_ANALYSIS
}
CameraMode.PHOTO -> {