diff --git a/library/src/main/api14/com/google/android/cameraview/Camera1.java b/library/src/main/api14/com/google/android/cameraview/Camera1.java index c15ffb69..74ca3832 100644 --- a/library/src/main/api14/com/google/android/cameraview/Camera1.java +++ b/library/src/main/api14/com/google/android/cameraview/Camera1.java @@ -27,6 +27,8 @@ import java.util.List; import java.util.Set; import java.util.SortedSet; +import java.util.concurrent.atomic.AtomicBoolean; + @SuppressWarnings("deprecation") class Camera1 extends CameraViewImpl { @@ -45,6 +47,8 @@ class Camera1 extends CameraViewImpl { private int mCameraId; + private final AtomicBoolean isPictureCaptureInProgress = new AtomicBoolean(false); + Camera mCamera; private Camera.Parameters mCameraParameters; @@ -227,14 +231,17 @@ public void onAutoFocus(boolean success, Camera camera) { } void takePictureInternal() { - mCamera.takePicture(null, null, null, new Camera.PictureCallback() { - @Override - public void onPictureTaken(byte[] data, Camera camera) { - mCallback.onPictureTaken(data); - camera.cancelAutoFocus(); - camera.startPreview(); - } - }); + if (!isPictureCaptureInProgress.getAndSet(true)) { + mCamera.takePicture(null, null, null, new Camera.PictureCallback() { + @Override + public void onPictureTaken(byte[] data, Camera camera) { + isPictureCaptureInProgress.set(false); + mCallback.onPictureTaken(data); + camera.cancelAutoFocus(); + camera.startPreview(); + } + }); + } } @Override