Skip to content

Commit 6b06c5d

Browse files
committed
let the dispose method delegate to stop() on Android
1 parent ee336cd commit 6b06c5d

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,6 @@ class MobileScanner(
170170
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
171171
}
172172

173-
/**
174-
* Create a barcode scanner from the given options.
175-
*
176-
* Can be overridden in tests.
177-
*/
178-
@VisibleForTesting
179-
fun createBarcodeScanner(options: BarcodeScannerOptions?) : BarcodeScanner {
180-
return if (options == null) BarcodeScanning.getClient() else BarcodeScanning.getClient(options)
181-
}
182-
183173
// scales the scanWindow to the provided inputImage and checks if that scaled
184174
// scanWindow contains the barcode
185175
private fun isBarcodeInScanWindow(
@@ -512,7 +502,10 @@ class MobileScanner(
512502
* Dispose of this scanner instance.
513503
*/
514504
fun dispose() {
515-
scanner?.close()
516-
scanner = null
505+
if (isStopped()) {
506+
return
507+
}
508+
509+
stop() // Defer to the stop method, which disposes all resources anyway.
517510
}
518511
}

0 commit comments

Comments
 (0)