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
yujune
2025-01-20 22:15:23 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
926da3d99f105670b28fa6f40fbcad27e4c4fb0a
926da3d9
1 parent
00715ccc
fix: fix android ui jank when returnImage set to true.
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
android/build.gradle
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
android/build.gradle
View file @
926da3d
...
...
@@ -79,6 +79,7 @@ dependencies {
implementation
'androidx.camera:camera-lifecycle:1.3.4'
implementation
'androidx.camera:camera-camera2:1.3.4'
implementation
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
testImplementation
'org.jetbrains.kotlin:kotlin-test'
testImplementation
'org.mockito:mockito-core:5.12.0'
...
...
android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt
View file @
926da3d
...
...
@@ -35,9 +35,12 @@ import dev.steenbakker.mobile_scanner.objects.DetectionSpeed
import dev.steenbakker.mobile_scanner.objects.MobileScannerStartParameters
import dev.steenbakker.mobile_scanner.utils.YuvToRgbConverter
import io.flutter.view.TextureRegistry
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import java.io.ByteArrayOutputStream
import kotlin.math.roundToInt
class MobileScanner(
private val activity: Activity,
private val textureRegistry: TextureRegistry,
...
...
@@ -97,6 +100,7 @@ class MobileScanner(
if (newScannedBarcodes == lastScanned) {
// New scanned is duplicate, returning
imageProxy.close()
return@addOnSuccessListener
}
if (newScannedBarcodes.isNotEmpty()) {
...
...
@@ -118,10 +122,12 @@ class MobileScanner(
}
if (barcodeMap.isEmpty()) {
imageProxy.close()
return@addOnSuccessListener
}
if (!returnImage) {
imageProxy.close()
mobileScannerCallback(
barcodeMap,
null,
...
...
@@ -130,6 +136,7 @@ class MobileScanner(
return@addOnSuccessListener
}
CoroutineScope(Dispatchers.IO).launch {
val bitmap = Bitmap.createBitmap(mediaImage.width, mediaImage.height, Bitmap.Config.ARGB_8888)
val imageFormat = YuvToRgbConverter(activity.applicationContext)
...
...
@@ -143,18 +150,20 @@ class MobileScanner(
val bmWidth = bmResult.width
val bmHeight = bmResult.height
bmResult.recycle()
imageProxy.close()
mobileScannerCallback(
barcodeMap,
byteArray,
bmWidth,
bmHeight
)
}
}.addOnFailureListener { e ->
mobileScannerErrorCallback(
e.localizedMessage ?: e.toString()
)
}
.addOnCompleteListener { imageProxy.close() }
}
}
if (detectionSpeed == DetectionSpeed.NORMAL) {
...
...
Please
register
or
login
to post a comment