Skip to content

Commit

Permalink
Fix ShutterCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
you-tiro committed Aug 30, 2018
1 parent 3b31c00 commit ae399d8
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class CameraFragment extends Fragment {
private MediaRecorder mMediaRecorder;//for video
private boolean isSurface = false;
private boolean isCapturing = false;
private boolean isShutter = false;
private File instanceRecordMP4;
private File instanceRecordWAV;
private MediaRecorder.OnInfoListener onInfoListener = new MediaRecorder.OnInfoListener() {
Expand Down Expand Up @@ -93,7 +94,11 @@ public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
private Camera.ShutterCallback onShutterCallback = new Camera.ShutterCallback() {
@Override
public void onShutter() {
mCallback.onShutter();
// ShutterCallback is called twice.
if (!isShutter) {
mCallback.onShutter();
isShutter = true;
}
}
};
private Camera.PictureCallback onJpegPictureCallback = new Camera.PictureCallback() {
Expand All @@ -110,6 +115,8 @@ public void onPictureTaken(byte[] data, Camera camera) {
e.printStackTrace();
}

mCallback.onPictureTaken();

mCamera.startPreview();
isCapturing = false;
}
Expand Down Expand Up @@ -208,6 +215,7 @@ public void stopWatching() {
public void takePicture() {
if (!isCapturing) {
isCapturing = true;
isShutter = false;

mParameters.setPictureSize(5376, 2688);
mParameters.set("RIC_SHOOTING_MODE", "RicStillCaptureStd");
Expand Down

0 comments on commit ae399d8

Please sign in to comment.