Showing
1 changed file
with
14 additions
and
10 deletions
| @@ -2,6 +2,8 @@ package dev.steenbakker.mobile_scanner | @@ -2,6 +2,8 @@ package dev.steenbakker.mobile_scanner | ||
| 2 | 2 | ||
| 3 | import android.app.Activity | 3 | import android.app.Activity |
| 4 | import android.net.Uri | 4 | import android.net.Uri |
| 5 | +import android.os.Handler | ||
| 6 | +import android.os.Looper | ||
| 5 | import android.util.Size | 7 | import android.util.Size |
| 6 | import androidx.camera.core.CameraSelector | 8 | import androidx.camera.core.CameraSelector |
| 7 | import androidx.camera.core.ExperimentalGetImage | 9 | import androidx.camera.core.ExperimentalGetImage |
| @@ -30,11 +32,12 @@ class MobileScannerHandler( | @@ -30,11 +32,12 @@ class MobileScannerHandler( | ||
| 30 | "name" to "barcode", | 32 | "name" to "barcode", |
| 31 | "data" to barcodes | 33 | "data" to barcodes |
| 32 | )) | 34 | )) |
| 33 | - analyzerResult?.success(true) | ||
| 34 | - } else { | ||
| 35 | - analyzerResult?.success(false) | ||
| 36 | } | 35 | } |
| 37 | - analyzerResult = null | 36 | + |
| 37 | + Handler(Looper.getMainLooper()).post { | ||
| 38 | + analyzerResult?.success(barcodes != null) | ||
| 39 | + analyzerResult = null | ||
| 40 | + } | ||
| 38 | } | 41 | } |
| 39 | 42 | ||
| 40 | private var analyzerResult: MethodChannel.Result? = null | 43 | private var analyzerResult: MethodChannel.Result? = null |
| @@ -92,7 +95,6 @@ class MobileScannerHandler( | @@ -92,7 +95,6 @@ class MobileScannerHandler( | ||
| 92 | if(listener != null) { | 95 | if(listener != null) { |
| 93 | activityPluginBinding.removeRequestPermissionsResultListener(listener) | 96 | activityPluginBinding.removeRequestPermissionsResultListener(listener) |
| 94 | } | 97 | } |
| 95 | - | ||
| 96 | } | 98 | } |
| 97 | 99 | ||
| 98 | @ExperimentalGetImage | 100 | @ExperimentalGetImage |
| @@ -173,11 +175,13 @@ class MobileScannerHandler( | @@ -173,11 +175,13 @@ class MobileScannerHandler( | ||
| 173 | torchStateCallback, | 175 | torchStateCallback, |
| 174 | zoomScaleStateCallback, | 176 | zoomScaleStateCallback, |
| 175 | mobileScannerStartedCallback = { | 177 | mobileScannerStartedCallback = { |
| 176 | - result.success(mapOf( | ||
| 177 | - "textureId" to it.id, | ||
| 178 | - "size" to mapOf("width" to it.width, "height" to it.height), | ||
| 179 | - "torchable" to it.hasFlashUnit | ||
| 180 | - )) | 178 | + Handler(Looper.getMainLooper()).post { |
| 179 | + result.success(mapOf( | ||
| 180 | + "textureId" to it.id, | ||
| 181 | + "size" to mapOf("width" to it.width, "height" to it.height), | ||
| 182 | + "torchable" to it.hasFlashUnit | ||
| 183 | + )) | ||
| 184 | + } | ||
| 181 | }, | 185 | }, |
| 182 | timeout.toLong(), | 186 | timeout.toLong(), |
| 183 | cameraResolution, | 187 | cameraResolution, |
-
Please register or login to post a comment