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:51 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
77a74708dabed0966f79b2eeb4ea89db907b6568
77a74708
1 parent
71ef50ee
handle errors from start() in callback
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
51 deletions
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt
View file @
77a7470
...
...
@@ -165,58 +165,60 @@ class MobileScannerHandler(
val detectionSpeed: DetectionSpeed = DetectionSpeed.values().first { it.intValue == speed}
try {
mobileScanner!!.start(
barcodeScannerOptions,
returnImage,
position,
torch,
detectionSpeed,
torchStateCallback,
zoomScaleStateCallback,
mobileScannerStartedCallback = {
Handler(Looper.getMainLooper()).post {
result.success(mapOf(
"textureId" to it.id,
"size" to mapOf("width" to it.width, "height" to it.height),
"torchable" to it.hasFlashUnit
))
mobileScanner!!.start(
barcodeScannerOptions,
returnImage,
position,
torch,
detectionSpeed,
torchStateCallback,
zoomScaleStateCallback,
mobileScannerStartedCallback = {
Handler(Looper.getMainLooper()).post {
result.success(mapOf(
"textureId" to it.id,
"size" to mapOf("width" to it.width, "height" to it.height),
"torchable" to it.hasFlashUnit
))
}
},
mobileScannerErrorCallback = {
Handler(Looper.getMainLooper()).post {
when (it) {
is AlreadyStarted -> {
result.error(
"MobileScanner",
"Called start() while already started",
null
)
}
is CameraError -> {
result.error(
"MobileScanner",
"Error occurred when setting up camera!",
null
)
}
is NoCamera -> {
result.error(
"MobileScanner",
"No camera found or failed to open camera!",
null
)
}
else -> {
result.error(
"MobileScanner",
"Unknown error occurred.",
null
)
}
}
},
timeout.toLong(),
cameraResolution,
)
} catch (e: AlreadyStarted) {
result.error(
"MobileScanner",
"Called start() while already started",
null
)
} catch (e: NoCamera) {
result.error(
"MobileScanner",
"No camera found or failed to open camera!",
null
)
} catch (e: TorchError) {
result.error(
"MobileScanner",
"Error occurred when setting torch!",
null
)
} catch (e: CameraError) {
result.error(
"MobileScanner",
"Error occurred when setting up camera!",
null
)
} catch (e: Exception) {
result.error(
"MobileScanner",
"Unknown error occurred..",
null
)
}
}
},
timeout.toLong(),
cameraResolution,
)
}
private fun stop(result: MethodChannel.Result) {
...
...
Please
register
or
login
to post a comment