Showing
1 changed file
with
8 additions
and
4 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,12 +32,13 @@ class MobileScannerHandler( | @@ -30,12 +32,13 @@ 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 | } |
| 36 | + | ||
| 37 | + Handler(Looper.getMainLooper()).post { | ||
| 38 | + analyzerResult?.success(barcodes != null) | ||
| 37 | analyzerResult = null | 39 | analyzerResult = null |
| 38 | } | 40 | } |
| 41 | + } | ||
| 39 | 42 | ||
| 40 | private var analyzerResult: MethodChannel.Result? = null | 43 | private var analyzerResult: MethodChannel.Result? = null |
| 41 | 44 | ||
| @@ -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 = { |
| 178 | + Handler(Looper.getMainLooper()).post { | ||
| 176 | result.success(mapOf( | 179 | result.success(mapOf( |
| 177 | "textureId" to it.id, | 180 | "textureId" to it.id, |
| 178 | "size" to mapOf("width" to it.width, "height" to it.height), | 181 | "size" to mapOf("width" to it.width, "height" to it.height), |
| 179 | "torchable" to it.hasFlashUnit | 182 | "torchable" to it.hasFlashUnit |
| 180 | )) | 183 | )) |
| 184 | + } | ||
| 181 | }, | 185 | }, |
| 182 | timeout.toLong(), | 186 | timeout.toLong(), |
| 183 | cameraResolution, | 187 | cameraResolution, |
-
Please register or login to post a comment