mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Remove nullability
This commit is contained in:
+5
-2
@@ -15,7 +15,7 @@ import timber.log.Timber
|
|||||||
import zxingcpp.BarcodeReader
|
import zxingcpp.BarcodeReader
|
||||||
|
|
||||||
internal class QRCodeAnalyzer(
|
internal class QRCodeAnalyzer(
|
||||||
private val onScanQrCode: (result: ByteArray?) -> Unit
|
private val onScanQrCode: (data: ByteArray) -> Unit
|
||||||
) : ImageAnalysis.Analyzer {
|
) : ImageAnalysis.Analyzer {
|
||||||
private val reader by lazy { BarcodeReader() }
|
private val reader by lazy { BarcodeReader() }
|
||||||
|
|
||||||
@@ -23,7 +23,10 @@ internal class QRCodeAnalyzer(
|
|||||||
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 }
|
||||||
bytes?.let { onScanQrCode(it) }
|
if (bytes != null) {
|
||||||
|
Timber.d("QR code scanned!")
|
||||||
|
onScanQrCode(bytes)
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.w(e, "Error decoding QR code")
|
Timber.w(e, "Error decoding QR code")
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+1
-6
@@ -80,12 +80,7 @@ fun QrCodeCameraView(
|
|||||||
.build()
|
.build()
|
||||||
imageAnalysis.setAnalyzer(
|
imageAnalysis.setAnalyzer(
|
||||||
ContextCompat.getMainExecutor(previewView.context),
|
ContextCompat.getMainExecutor(previewView.context),
|
||||||
QRCodeAnalyzer { result ->
|
QRCodeAnalyzer(onScanQrCode)
|
||||||
result?.let {
|
|
||||||
Timber.d("QR code scanned!")
|
|
||||||
onScanQrCode(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
// Make sure we unbind all use cases before binding them again
|
// Make sure we unbind all use cases before binding them again
|
||||||
|
|||||||
Reference in New Issue
Block a user