Skip to content

Commit

Permalink
Fix crash when scan returns null response
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmangubat23 committed Jun 29, 2022
1 parent 2b8c63d commit fff13ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class MainActivity : AppCompatActivity() {
// Get Result from JSON String
val result = intent?.getStringExtra(SCANNER_RESULT)
Log.d(SmartScannerActivity.TAG, "Scanner result string: $result")
if (result != null) {
if (!result.isNullOrEmpty()) {
// Go to Barcode/MRZ Results Screen
val resultIntent = Intent(this, ResultActivity::class.java)
resultIntent.putExtra(ResultActivity.RESULT, result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class BarcodeAnalyzer(
.addOnSuccessListener { barcodes ->
val timeRequired = System.currentTimeMillis() - start
val cornersString: String
val rawValue: String
val rawValue: String?
Log.d(
"${SmartScannerActivity.TAG}/SmartScanner",
"barcode: success: $timeRequired ms"
Expand All @@ -89,10 +89,10 @@ class BarcodeAnalyzer(
imageProxy.imageInfo.rotationDegrees
)
cornersString = builder.toString()
rawValue = barcodes[0].rawValue!!
rawValue = barcodes[0].rawValue
val bitmapResult = if (isPDF417) bf.getResizedBitmap(480, 640) else bf
val imageResult = if (imageResultType == ImageResultType.BASE_64.value) bitmapResult?.encodeBase64(rot) else filePath
val result = BarcodeResult(imagePath = filePath, image = imageResult, corners= cornersString, value = rawValue)
val result = BarcodeResult(imagePath = filePath, image = imageResult, corners = cornersString, value = rawValue)
when (intent.action) {
ScannerConstants.IDPASS_SMARTSCANNER_BARCODE_INTENT,
ScannerConstants.IDPASS_SMARTSCANNER_ODK_BARCODE_INTENT -> {
Expand Down Expand Up @@ -121,7 +121,7 @@ class BarcodeAnalyzer(
}
}

private fun sendAnalyzerResult(result: String? = null) {
private fun sendAnalyzerResult(result: String) {
val data = Intent()
Log.d(SmartScannerActivity.TAG, "Success from BARCODE")
Log.d(SmartScannerActivity.TAG, "value: $result")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ open class MRZAnalyzer(
}
}

private fun sendAnalyzerResult(result: String? = null) {
private fun sendAnalyzerResult(result: String) {
val data = Intent()
Log.d(SmartScannerActivity.TAG, "Success from MRZ")
Log.d(SmartScannerActivity.TAG, "value: $result")
Expand Down

0 comments on commit fff13ad

Please sign in to comment.