Skip to content

Commit

Permalink
fixed passing params to CameraActivity.java. Added try/catch to clear…
Browse files Browse the repository at this point in the history
…Focus method in CameraPreview.java
  • Loading branch information
shliama committed Oct 7, 2014
1 parent 0483345 commit d160d60
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public void onCreate(Bundle savedInstanceState) {
if (TextUtils.isEmpty(path = getIntent().getStringExtra(PATH))) {
path = Environment.getExternalStorageDirectory().getPath();
}
openPreview = SharedPrefManager.i.isOpenPhotoPreview();
if (openPreview != getIntent().getBooleanExtra(OPEN_PHOTO_PREVIEW, openPreview)) {
openPreview = getIntent().getBooleanExtra(OPEN_PHOTO_PREVIEW, SharedPrefManager.i.isOpenPhotoPreview());
if (openPreview != SharedPrefManager.i.isOpenPhotoPreview()) {
SharedPrefManager.i.setOpenPhotoPreview(openPreview);
}
boolean useFrontCamera = getIntent().getBooleanExtra(USE_FRONT_CAMERA, SharedPrefManager.i.useFrontCamera());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,18 @@ private void clearCameraFocus() {
camera.cancelAutoFocus();
if (canvas != null) {
tapArea = null;
Camera.Parameters parameters = camera.getParameters();
parameters.setFocusAreas(null);
parameters.setMeteringAreas(null);
camera.setParameters(parameters);
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
canvasFrame.draw(canvas);
canvasFrame.invalidate();
try {
Camera.Parameters parameters = camera.getParameters();
parameters.setFocusAreas(null);
parameters.setMeteringAreas(null);
camera.setParameters(parameters);
} catch (Exception e) {
Timber.e(e, "clearCameraFocus");
} finally {
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
canvasFrame.draw(canvas);
canvasFrame.invalidate();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void openCamera(View view) {
intent.putExtra(CameraActivity.PATH, Const.FOLDERS.PATH);
intent.putExtra(CameraActivity.OPEN_PHOTO_PREVIEW, true);
intent.putExtra(CameraActivity.LAYOUT_ID, R.layout.fragment_camera_custom);
intent.putExtra(CameraActivity.USE_FRONT_CAMERA, true);
intent.putExtra(CameraActivity.USE_FRONT_CAMERA, false);
startActivity(intent);
}

Expand Down

0 comments on commit d160d60

Please sign in to comment.