Skip to content

Commit

Permalink
Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuriy Budiyev committed Jan 9, 2018
1 parent 83b19a1 commit 9cc025f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/budiyev/android/codescanner/CodeScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ public boolean onStateChanged(@NonNull Decoder decoder, @NonNull Decoder.State s
return false;
} else if (scanMode == ScanMode.SINGLE) {
mStoppingPreview = true;
decoder.setForceSkip(true);
mMainThreadHandler.post(new StopPreviewTask(decoder));
decoder.setFinishingScan(true);
mMainThreadHandler.post(new FinishScanTask(decoder));
}
}
return true;
Expand Down Expand Up @@ -731,17 +731,17 @@ public void run() {
}
}

private final class StopPreviewTask implements Runnable {
private final class FinishScanTask implements Runnable {
private final Decoder mDecoder;

private StopPreviewTask(@NonNull Decoder decoder) {
private FinishScanTask(@NonNull Decoder decoder) {
mDecoder = decoder;
}

@Override
public void run() {
stopPreview();
mDecoder.setForceSkip(false);
mDecoder.setFinishingScan(false);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/budiyev/android/codescanner/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class Decoder {
private final Map<DecodeHintType, Object> mHints;
private volatile DecodeCallback mCallback;
private volatile boolean mProcessingResult;
private volatile boolean mForceSkip;
private volatile boolean mFinishingScan;

public Decoder(@NonNull StateListener stateListener, @NonNull List<BarcodeFormat> formats,
@Nullable DecodeCallback callback) {
Expand Down Expand Up @@ -83,11 +83,11 @@ public void shutdown() {
}

public boolean shouldSkipTask() {
return mForceSkip || mProcessingResult || mDecodeQueue.remainingCapacity() == 0;
return mFinishingScan || mProcessingResult || mDecodeQueue.remainingCapacity() == 0;
}

public void setForceSkip(boolean forceSkip) {
mForceSkip = forceSkip;
public void setFinishingScan(boolean finishing) {
mFinishingScan = finishing;
}

private final class DecoderThread extends Thread {
Expand Down

0 comments on commit 9cc025f

Please sign in to comment.