diff --git a/qrcodereaderview/src/main/java/com/dlazaro66/qrcodereaderview/QRCodeReaderView.java b/qrcodereaderview/src/main/java/com/dlazaro66/qrcodereaderview/QRCodeReaderView.java index a1a2f47..a528018 100644 --- a/qrcodereaderview/src/main/java/com/dlazaro66/qrcodereaderview/QRCodeReaderView.java +++ b/qrcodereaderview/src/main/java/com/dlazaro66/qrcodereaderview/QRCodeReaderView.java @@ -48,11 +48,11 @@ public class QRCodeReaderView extends SurfaceView public interface OnQRCodeReadListener { - public void onQRCodeRead(String text, PointF[] points); + void onQRCodeRead(String text, PointF[] points); - public void cameraNotFound(); + void cameraNotFound(); - public void QRCodeNotFoundOnCamImage(); + void QRCodeNotFoundOnCamImage(); } private OnQRCodeReadListener mOnQRCodeReadListener; @@ -64,6 +64,7 @@ public interface OnQRCodeReadListener { private int mPreviewHeight; private SurfaceHolder mHolder; private CameraManager mCameraManager; + private boolean mQrDecodingEnabled = true; public QRCodeReaderView(Context context) { super(context); @@ -79,6 +80,10 @@ public void setOnQRCodeReadListener(OnQRCodeReadListener onQRCodeReadListener) { mOnQRCodeReadListener = onQRCodeReadListener; } + public void setQRDecodingEnabled(boolean qrDecodingEnabled) { + this.mQrDecodingEnabled = qrDecodingEnabled; + } + public CameraManager getCameraManager() { return mCameraManager; } @@ -131,6 +136,9 @@ public CameraManager getCameraManager() { // Called when camera take a frame @Override public void onPreviewFrame(byte[] data, Camera camera) { + if (!mQrDecodingEnabled) { + return; + } PlanarYUVLuminanceSource source = mCameraManager.buildLuminanceSource(data, mPreviewWidth, mPreviewHeight); @@ -198,7 +206,6 @@ public CameraManager getCameraManager() { * @return a new PointF array with transformed points */ private PointF[] transformToViewCoordinates(ResultPoint[] resultPoints) { - PointF[] transformedPoints = new PointF[resultPoints.length]; int index = 0; if (resultPoints != null) {