From 69e9d8a8c79e92c0d90af41b761173531f0e8c18 Mon Sep 17 00:00:00 2001 From: aiWean <1581209979@qq.com> Date: Sun, 16 Aug 2020 14:49:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++--- .../google/android/cameraview/Camera1.java | 8 ++++--- .../google/android/cameraview/Camera2.java | 22 +++++++------------ .../com/ailiwean/core/able/AbleManager.kt | 4 +++- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 7903d41..c45ea90 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ ``` - implementation 'com.github.ailiwean:NBZxing:0.0.21' - //若需要使用灰度算法增强库,再次添加以下依赖 + implementation 'com.github.ailiwean:NBZxing:0.0.21' + //若需要使用灰度算法增强库,再次添加以下依赖 //纯java版超轻量 implementation 'com.github.ailiwean:NBZxing-Scale:0.0.1' ``` **注意:库中已经包含zxing源码无需再次依赖** @@ -138,5 +138,4 @@ protected open fun resultBackFile(content: String) { 微信: 17391961576 QQ: 1581209979 -白嫖这种行为不好啊😄 ![pay](https://github.com/ailiwean/NBZxing/blob/master/qr_test/pay.png "pay") diff --git a/module_camera/src/main/api14/com/google/android/cameraview/Camera1.java b/module_camera/src/main/api14/com/google/android/cameraview/Camera1.java index 4bbc4e4..9fbfd5c 100644 --- a/module_camera/src/main/api14/com/google/android/cameraview/Camera1.java +++ b/module_camera/src/main/api14/com/google/android/cameraview/Camera1.java @@ -282,17 +282,19 @@ void setDisplayOrientation(int displayOrientation) { @Override void toZoomMax() { - CameraHelper.setZoom(1, mCamera); + setZoom(1); } @Override void toZoomMin() { - CameraHelper.setZoom(0, mCamera); + setZoom(0); } @Override void setZoom(float percent) { - CameraHelper.setZoom(percent, mCamera); + synchronized (Camera1.class) { + CameraHelper.setZoom(percent, mCamera); + } } @Override diff --git a/module_camera/src/main/api21/com/google/android/cameraview/Camera2.java b/module_camera/src/main/api21/com/google/android/cameraview/Camera2.java index 4604625..931d03e 100644 --- a/module_camera/src/main/api21/com/google/android/cameraview/Camera2.java +++ b/module_camera/src/main/api21/com/google/android/cameraview/Camera2.java @@ -355,28 +355,22 @@ void setDisplayOrientation(int displayOrientation) { @Override void toZoomMax() { - try { - mPreviewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, CameraHelper.getZoomRect(mCameraCharacteristics, 1)); - mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), mCaptureCallback, null); - } catch (Exception e) { - } + setZoom(1); } @Override void toZoomMin() { - try { - mPreviewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, CameraHelper.getZoomRect(mCameraCharacteristics, 0)); - mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), mCaptureCallback, null); - } catch (Exception e) { - } + setZoom(0); } @Override void setZoom(float percent) { - try { - mPreviewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, CameraHelper.getZoomRect(mCameraCharacteristics, percent)); - mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), mCaptureCallback, null); - } catch (Exception e) { + synchronized (Camera2.class) { + try { + mPreviewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, CameraHelper.getZoomRect(mCameraCharacteristics, percent)); + mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), mCaptureCallback, null); + } catch (Exception e) { + } } } diff --git a/module_camera/src/main/java/com/ailiwean/core/able/AbleManager.kt b/module_camera/src/main/java/com/ailiwean/core/able/AbleManager.kt index f5dc5ad..d0cb124 100644 --- a/module_camera/src/main/java/com/ailiwean/core/able/AbleManager.kt +++ b/module_camera/src/main/java/com/ailiwean/core/able/AbleManager.kt @@ -61,9 +61,9 @@ class AbleManager private constructor(handler: Handler) : PixsValuesAble(handler } private fun grayscaleProcess(data: ByteArray, dataWidth: Int, dataHeight: Int) { - grayProcessHandler.removeCallbacksAndMessages(null) if (processClz == null) return + grayProcessHandler.removeCallbacksAndMessages(null) grayProcessHandler.post { val newByte = processDispatch!!.dispatch(data, dataWidth, dataHeight) if (newByte.isNotEmpty()) @@ -94,6 +94,8 @@ class AbleManager private constructor(handler: Handler) : PixsValuesAble(handler fun release() { ableList.clear() server.quit() + if (processClz == null) + return grayProcessHandler.looper.quit() }