Check focus area max number before applying (#167)

pull/168/head
Mattia Iavarone 7 years ago committed by GitHub
parent bcb2cfeb7f
commit ef1a4ecc65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java

@ -38,8 +38,10 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
if (!isCameraAvailable()) return; if (!isCameraAvailable()) return;
mCamera.cancelAutoFocus(); mCamera.cancelAutoFocus();
Camera.Parameters params = mCamera.getParameters(); Camera.Parameters params = mCamera.getParameters();
params.setFocusAreas(null); int maxAF = params.getMaxNumFocusAreas();
params.setMeteringAreas(null); int maxAE = params.getMaxNumMeteringAreas();
if (maxAF > 0) params.setFocusAreas(null);
if (maxAE > 0) params.setMeteringAreas(null);
applyDefaultFocus(params); // Revert to internal focus. applyDefaultFocus(params); // Revert to internal focus.
mCamera.setParameters(params); mCamera.setParameters(params);
} }

Loading…
Cancel
Save