Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 2821c1d

Browse files
committed
Fix Exception for calling stop in onPictureTaken Callback
Fixes bug #67
1 parent 6ceaf86 commit 2821c1d

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

library/src/main/api14/com/google/android/cameraview/Camera1.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ void takePictureInternal() {
243243
public void onPictureTaken(byte[] data, Camera camera) {
244244
isPictureCaptureInProgress.set(false);
245245
mCallback.onPictureTaken(data);
246+
if (!isCameraOpened()) return;
246247
camera.cancelAutoFocus();
247248
camera.startPreview();
248249
}

library/src/main/api21/com/google/android/cameraview/Camera2.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ public void onCaptureCompleted(@NonNull CameraCaptureSession session,
650650
* capturing a still picture.
651651
*/
652652
void unlockFocus() {
653+
if (!isCameraOpened()) return;
653654
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
654655
CaptureRequest.CONTROL_AF_TRIGGER_CANCEL);
655656
try {

0 commit comments

Comments
 (0)