From f5c20ec40853178ee4800e30772edb4421c47390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carreira?= Date: Mon, 9 Dec 2024 11:15:25 +0000 Subject: [PATCH] fix: missing parenthesis --- .../steenbakker/mobile_scanner/MobileScanner.kt | 14 +++++--------- .../mobile_scanner/MobileScannerHandler.kt | 1 + 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt b/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt index 14cac1653..17f92faa0 100644 --- a/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt +++ b/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt @@ -44,7 +44,7 @@ class MobileScanner( private val textureRegistry: TextureRegistry, private val mobileScannerCallback: MobileScannerCallback, private val mobileScannerErrorCallback: MobileScannerErrorCallback, - private val barcodeScannerFactory: (options: BarcodeScannerOptions?) -> BarcodeScanner = ::defaultBarcodeScannerFactory, + private val barcodeScannerFactory: (options: BarcodeScannerOptions.Builder?) -> BarcodeScanner = ::defaultBarcodeScannerFactory, ) { /// Internal variables @@ -67,8 +67,8 @@ class MobileScanner( /** * Create a barcode scanner from the given options. */ - fun defaultBarcodeScannerFactory(options: BarcodeScannerOptions?) : BarcodeScanner { - return if (options == null) BarcodeScanning.getClient() else BarcodeScanning.getClient(options) + fun defaultBarcodeScannerFactory(options: BarcodeScannerOptions.Builder?) : BarcodeScanner { + return if (options == null) BarcodeScanning.getClient() else BarcodeScanning.getClient(options.build()) } } @@ -266,11 +266,7 @@ class MobileScanner( null } - scanner = if (barcodeScannerOptions != null) { - BarcodeScanning.getClient(barcodeScannerOptions.build()) - } else { - BarcodeScanning.getClient() - } + scanner = barcodeScannerFactory(barcodeScannerOptions) val cameraProviderFuture = ProcessCameraProvider.getInstance(activity) val executor = ContextCompat.getMainExecutor(activity) @@ -492,7 +488,7 @@ class MobileScanner( */ fun analyzeImage( image: Uri, - scannerOptions: BarcodeScannerOptions?, + scannerOptions: BarcodeScannerOptions.Builder?, onSuccess: AnalyzerSuccessCallback, onError: AnalyzerErrorCallback) { val inputImage = InputImage.fromFilePath(activity, image) diff --git a/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt b/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt index 048506510..08d7e9fd7 100644 --- a/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt +++ b/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt @@ -289,5 +289,6 @@ class MobileScannerHandler( return BarcodeScannerOptions.Builder().setBarcodeFormats( formatsList.first(), *formatsList.subList(1, formatsList.size).toIntArray() + ) } }