Navaron Bracke

let the dispose method delegate to stop() on Android

@@ -170,16 +170,6 @@ class MobileScanner( @@ -170,16 +170,6 @@ class MobileScanner(
170 return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true) 170 return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
171 } 171 }
172 172
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 -  
183 // scales the scanWindow to the provided inputImage and checks if that scaled 173 // scales the scanWindow to the provided inputImage and checks if that scaled
184 // scanWindow contains the barcode 174 // scanWindow contains the barcode
185 private fun isBarcodeInScanWindow( 175 private fun isBarcodeInScanWindow(
@@ -512,7 +502,10 @@ class MobileScanner( @@ -512,7 +502,10 @@ class MobileScanner(
512 * Dispose of this scanner instance. 502 * Dispose of this scanner instance.
513 */ 503 */
514 fun dispose() { 504 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.
517 } 510 }
518 } 511 }