From 326183314ccce0ea9837a604f2a5a39cee50521f Mon Sep 17 00:00:00 2001 From: Robin Genz Date: Thu, 4 May 2023 20:01:26 +0200 Subject: [PATCH] fix(barcode-scanning): `readBarcodesFromImage(...)` throws a null exception on Android --- .changeset/slow-snakes-relate.md | 5 +++++ .../plugins/mlkit/barcodescanning/BarcodeScannerHelper.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/slow-snakes-relate.md diff --git a/.changeset/slow-snakes-relate.md b/.changeset/slow-snakes-relate.md new file mode 100644 index 0000000..691283f --- /dev/null +++ b/.changeset/slow-snakes-relate.md @@ -0,0 +1,5 @@ +--- +'@capacitor-mlkit/barcode-scanning': patch +--- + +fix(android): `readBarcodesFromImage(...)` throws a null exception diff --git a/packages/barcode-scanning/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/barcodescanning/BarcodeScannerHelper.java b/packages/barcode-scanning/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/barcodescanning/BarcodeScannerHelper.java index 8da0148..413aa7c 100644 --- a/packages/barcode-scanning/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/barcodescanning/BarcodeScannerHelper.java +++ b/packages/barcode-scanning/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/barcodescanning/BarcodeScannerHelper.java @@ -21,7 +21,7 @@ public class BarcodeScannerHelper { public static JSObject createBarcodeResultForBarcode(@NonNull Barcode barcode, @Nullable Point imageSize, @Nullable Point screenSize) { Point[] cornerPoints = barcode.getCornerPoints(); JSArray cornerPointsResult = new JSArray(); - if (cornerPoints != null || imageSize != null || screenSize != null) { + if (cornerPoints != null && imageSize != null && screenSize != null) { Point[] normalizedCornerPoints = normalizeCornerPoints(cornerPoints, imageSize, screenSize); for (int i = 0; i < normalizedCornerPoints.length; i++) { JSArray cornerPointResult = new JSArray();