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
2024-09-10 11:36:45 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
69504bfc226616901f71fce80464ecc4b7cd78ff
69504bfc
1 parent
2d767fdf
move barcode scanner options builder into method for android
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
18 deletions
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt
View file @
69504bf
...
...
@@ -151,28 +151,16 @@ class MobileScannerHandler(
null
}
var barcodeScannerOptions: BarcodeScannerOptions? = null
if (formats != null) {
val formatsList: MutableList<Int> = mutableListOf()
for (formatValue in formats) {
formatsList.add(BarcodeFormats.fromRawValue(formatValue).intValue)
}
barcodeScannerOptions = if (formatsList.size == 1) {
BarcodeScannerOptions.Builder().setBarcodeFormats(formatsList.first())
.build()
} else {
BarcodeScannerOptions.Builder().setBarcodeFormats(
formatsList.first(),
*formatsList.subList(1, formatsList.size).toIntArray()
).build()
}
}
val barcodeScannerOptions: BarcodeScannerOptions? = buildBarcodeScannerOptions(formats)
val position =
if (facing == 0) CameraSelector.DEFAULT_FRONT_CAMERA else CameraSelector.DEFAULT_BACK_CAMERA
val detectionSpeed: DetectionSpeed = if (speed == 0) DetectionSpeed.NO_DUPLICATES
else if (speed ==1) DetectionSpeed.NORMAL else DetectionSpeed.UNRESTRICTED
val detectionSpeed: DetectionSpeed = when (speed) {
0 -> DetectionSpeed.NO_DUPLICATES
1 -> DetectionSpeed.NORMAL
else -> DetectionSpeed.UNRESTRICTED
}
mobileScanner!!.start(
barcodeScannerOptions,
...
...
@@ -284,4 +272,26 @@ class MobileScannerHandler(
result.success(null)
}
private fun buildBarcodeScannerOptions(formats: List<Int>?): BarcodeScannerOptions? {
if (formats == null) {
return null
}
val formatsList: MutableList<Int> = mutableListOf()
for (formatValue in formats) {
formatsList.add(BarcodeFormats.fromRawValue(formatValue).intValue)
}
if (formatsList.size == 1) {
return BarcodeScannerOptions.Builder().setBarcodeFormats(formatsList.first())
.build()
}
return BarcodeScannerOptions.Builder().setBarcodeFormats(
formatsList.first(),
*formatsList.subList(1, formatsList.size).toIntArray()
).build()
}
}
...
...
Please
register
or
login
to post a comment