Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2023-10-29 15:15:01 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
71ef50ee508b9583c31c3f1fa6a51e2a75d8ca05
71ef50ee
1 parent
2ae34d2a
forward errors from camera provider
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
View file @
71ef50e
...
...
@@ -28,7 +28,6 @@ import android.view.WindowManager
import android.content.Context
import android.os.Build
class MobileScanner(
private val activity: Activity,
private val textureRegistry: TextureRegistry,
...
...
@@ -213,6 +212,7 @@ class MobileScanner(
torchStateCallback: TorchStateCallback,
zoomScaleStateCallback: ZoomScaleStateCallback,
mobileScannerStartedCallback: MobileScannerStartedCallback,
mobileScannerErrorCallback: (exception: Exception) -> Unit,
detectionTimeout: Long,
cameraResolution: Size?
) {
...
...
@@ -221,7 +221,9 @@ class MobileScanner(
this.returnImage = returnImage
if (camera?.cameraInfo != null && preview != null && textureEntry != null) {
throw AlreadyStarted()
mobileScannerErrorCallback(AlreadyStarted())
return
}
scanner = if (barcodeScannerOptions != null) {
...
...
@@ -237,7 +239,9 @@ class MobileScanner(
cameraProvider = cameraProviderFuture.get()
if (cameraProvider == null) {
throw CameraError()
mobileScannerErrorCallback(CameraError())
return@addListener
}
cameraProvider?.unbindAll()
...
...
@@ -292,12 +296,18 @@ class MobileScanner(
val analysis = analysisBuilder.build().apply { setAnalyzer(executor, captureOutput) }
camera = cameraProvider!!.bindToLifecycle(
activity as LifecycleOwner,
cameraPosition,
preview,
analysis
)
try {
camera = cameraProvider?.bindToLifecycle(
activity as LifecycleOwner,
cameraPosition,
preview,
analysis
)
} catch(exception: Exception) {
mobileScannerErrorCallback(NoCamera())
return@addListener
}
camera?.let {
// Register the torch listener
...
...
Please
register
or
login
to post a comment