Skip to content

Commit 43698d3

Browse files
committed
当缩小之后不再自动放大
1 parent bed5d20 commit 43698d3

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

czxing/src/main/java/me/devilsen/czxing/camera/CameraSurface.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class CameraSurface extends SurfaceView implements SensorController.Camer
3030
private boolean mIsTouchFocusing;
3131
private boolean mSurfaceCreated;
3232
private boolean mFlashLightIsOpen;
33+
private boolean mZoomOutFlag;
3334

3435
private Point focusCenter;
3536
private long mLastTouchTime;
@@ -241,6 +242,7 @@ void handleZoom(boolean isZoomIn, int scale) {
241242
zoom += scale;
242243
} else if (!isZoomIn && zoom > 0) {
243244
BarCodeUtil.d("缩小");
245+
mZoomOutFlag = true;
244246
zoom -= scale;
245247
} else {
246248
BarCodeUtil.d("既不放大也不缩小");
@@ -333,6 +335,15 @@ public boolean isPreviewing() {
333335
return mCamera != null && mPreviewing && mSurfaceCreated;
334336
}
335337

338+
/**
339+
* 是否有过缩小操作
340+
*
341+
* @return true:缩小过
342+
*/
343+
public boolean hadZoomOut() {
344+
return mZoomOutFlag;
345+
}
346+
336347
private void handleFocus(float x, float y) {
337348
float centerX = x;
338349
float centerY = y;

czxing/src/main/java/me/devilsen/czxing/view/BarCoderView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import android.graphics.Rect;
66
import android.hardware.Camera;
77
import android.util.AttributeSet;
8-
import android.util.Log;
98
import android.view.ViewGroup;
109
import android.view.animation.AccelerateDecelerateInterpolator;
1110
import android.widget.FrameLayout;
@@ -309,7 +308,7 @@ void tryZoom(CodeResult result) {
309308

310309
private void handleAutoZoom(int len) {
311310
try {
312-
if (mCamera == null || mScanBoxView == null || len <= 0) {
311+
if (mCamera == null || mScanBoxView == null || len <= 0 || mCameraSurface.hadZoomOut()) {
313312
return;
314313
}
315314

0 commit comments

Comments
 (0)