Prevent NPE

pull/214/head
M66B 2 years ago
parent 915e9fc36f
commit d7a7afca24

@ -224,16 +224,18 @@ public class AdapterMedia extends RecyclerView.Adapter<AdapterMedia.ViewHolder>
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
try (InputStream is = new FileInputStream(file)) { try (InputStream is = new FileInputStream(file)) {
Bitmap bitmap = ImageHelper.getScaledBitmap(is, file.getAbsolutePath(), type, max); Bitmap bitmap = ImageHelper.getScaledBitmap(is, file.getAbsolutePath(), type, max);
int width = bitmap.getWidth(), height = bitmap.getHeight(); if (bitmap != null) {
int[] pixels = new int[width * height]; int width = bitmap.getWidth(), height = bitmap.getHeight();
bitmap.getPixels(pixels, 0, width, 0, 0, width, height); int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
BinaryBitmap bBitmap = new BinaryBitmap(new HybridBinarizer(source)); RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
MultiFormatReader reader = new MultiFormatReader(); BinaryBitmap bBitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result = reader.decode(bBitmap); MultiFormatReader reader = new MultiFormatReader();
args.putString("barcode_text", Helper.getPrintableString(result.getText(), false)); Result result = reader.decode(bBitmap);
args.putString("barcode_format", result.getBarcodeFormat().name()); args.putString("barcode_text", Helper.getPrintableString(result.getText(), false));
args.putString("barcode_format", result.getBarcodeFormat().name());
}
} catch (NotFoundException ex) { } catch (NotFoundException ex) {
Log.i(ex); Log.i(ex);
} catch (Throwable ex) { } catch (Throwable ex) {

Loading…
Cancel
Save