add error handling for capturing images

pull/59/merge^2
Tim H 7 years ago
parent 1f748c36ae
commit 4b72db41d0
  1. 15
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java

@ -428,6 +428,7 @@ class Camera1 extends CameraController {
if (!mOptions.isVideoSnapshotSupported()) return false;
}
try {
// Set boolean to wait for image callback
mIsCapturingImage = true;
final int exifRotation = computeExifRotation();
@ -459,6 +460,12 @@ class Camera1 extends CameraController {
});
return true;
}
catch (Exception e) {
CameraException cameraException = new CapturingPictureFailedException("Capturing a picture failed.", e);
mCameraCallbacks.onError(cameraException);
return false;
}
}
@Override
@ -471,6 +478,8 @@ class Camera1 extends CameraController {
capturePicture();
return false;
}
try {
mIsCapturingImage = true;
mCamera.setOneShotPreviewCallback(new Camera.PreviewCallback() {
@Override
@ -503,6 +512,12 @@ class Camera1 extends CameraController {
});
return true;
}
catch (Exception e) {
CameraException cameraException = new CapturingSnapshotFailedException("Capturing a snapshot failed.", e);
mCameraCallbacks.onError(cameraException);
return false;
}
}
@Override
boolean shouldFlipSizes() {

Loading…
Cancel
Save