Skip to content

Commit

Permalink
Revert "Dev"
Browse files Browse the repository at this point in the history
This reverts commit de40a7f.
  • Loading branch information
Yuriy Budiyev committed Aug 31, 2017
1 parent de40a7f commit 6224c15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta3'
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
Expand Down Expand Up @@ -65,7 +65,7 @@ android {
dependencies {
api 'com.google.zxing:core:3.3.0'
api 'com.google.zxing:android-core:3.3.0'
api 'com.android.support:support-annotations:26.0.2'
api 'com.android.support:support-annotations:26.0.1'
}

group = publishedGroupId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public final class CodeScanner {
BarcodeFormat.PDF_417, BarcodeFormat.QR_CODE);
private static final long AUTO_FOCUS_INTERVAL = 1000L;
private static final int UNSPECIFIED = -1;
private static final int FOCUS_ATTEMPTS_THRESHOLD = 2;
private final Lock mInitializeLock = new ReentrantLock();
private final Context mContext;
private final Handler mMainThreadHandler;
Expand All @@ -90,6 +91,7 @@ public final class CodeScanner {
private volatile boolean mStoppingPreview;
private boolean mPreviewActive;
private boolean mFocusing;
private int mFocusAttemptsCount;

/**
* CodeScanner, associated with the first back-facing camera on the device
Expand Down Expand Up @@ -272,6 +274,7 @@ private void startPreviewInternal() {
mStoppingPreview = false;
mPreviewActive = true;
mFocusing = false;
mFocusAttemptsCount = 0;
scheduleAutoFocusTask();
} catch (Exception ignored) {
}
Expand All @@ -286,18 +289,21 @@ private void stopPreviewInternal() {
mStoppingPreview = false;
mPreviewActive = false;
mFocusing = false;
mFocusAttemptsCount = 0;
}

private void autoFocusCamera() {
if (!mInitialized || !mPreviewActive) {
return;
}
if (mFocusing) {
if (mFocusing && mFocusAttemptsCount < FOCUS_ATTEMPTS_THRESHOLD) {
mFocusAttemptsCount++;
scheduleAutoFocusTask();
return;
}
try {
mCamera.autoFocus(mAutoFocusCallback);
mFocusAttemptsCount = 0;
mFocusing = true;
} catch (Exception e) {
mFocusing = false;
Expand Down Expand Up @@ -417,6 +423,7 @@ private final class AutoFocusCallback implements Camera.AutoFocusCallback {
@Override
public void onAutoFocus(boolean success, Camera camera) {
mFocusing = false;
scheduleAutoFocusTask();
}
}

Expand Down

0 comments on commit 6224c15

Please sign in to comment.