Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
ailiwean committed Aug 16, 2020
1 parent 25ef8c2 commit 69e9d8a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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源码无需再次依赖**
Expand Down Expand Up @@ -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")
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 69e9d8a

Please sign in to comment.