mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 01:19:33 +00:00
Improve code
This commit is contained in:
+4
-2
@@ -20,6 +20,7 @@ internal class QRCodeAnalyzer(
|
|||||||
private val reader by lazy { BarcodeReader() }
|
private val reader by lazy { BarcodeReader() }
|
||||||
|
|
||||||
override fun analyze(image: ImageProxy) {
|
override fun analyze(image: ImageProxy) {
|
||||||
|
image.use {
|
||||||
if (image.format in SUPPORTED_IMAGE_FORMATS) {
|
if (image.format in SUPPORTED_IMAGE_FORMATS) {
|
||||||
try {
|
try {
|
||||||
val bytes = reader.read(image).firstNotNullOfOrNull { it.bytes }
|
val bytes = reader.read(image).firstNotNullOfOrNull { it.bytes }
|
||||||
@@ -29,8 +30,9 @@ internal class QRCodeAnalyzer(
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.w(e, "Error decoding QR code")
|
Timber.w(e, "Error decoding QR code")
|
||||||
} finally {
|
}
|
||||||
image.close()
|
} else {
|
||||||
|
Timber.w("Unsupported image format: ${image.format}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user