Improve code
This commit is contained in:
parent
4f5ce5711d
commit
efa5c7794d
1 changed files with 12 additions and 10 deletions
|
|
@ -20,6 +20,7 @@ internal class QRCodeAnalyzer(
|
|||
private val reader by lazy { BarcodeReader() }
|
||||
|
||||
override fun analyze(image: ImageProxy) {
|
||||
image.use {
|
||||
if (image.format in SUPPORTED_IMAGE_FORMATS) {
|
||||
try {
|
||||
val bytes = reader.read(image).firstNotNullOfOrNull { it.bytes }
|
||||
|
|
@ -29,8 +30,9 @@ internal class QRCodeAnalyzer(
|
|||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.w(e, "Error decoding QR code")
|
||||
} finally {
|
||||
image.close()
|
||||
}
|
||||
} else {
|
||||
Timber.w("Unsupported image format: ${image.format}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue