Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Nullpointer when setting picture size parameter in Camera1 #207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions library/src/main/api14/com/google/android/cameraview/Camera1.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,19 @@ void adjustCameraParameters() {
}
Size size = chooseOptimalSize(sizes);

// Always re-apply camera parameters
// Largest picture size in this ratio
final Size pictureSize = mPictureSizes.sizes(mAspectRatio).last();
final Size pictureSize;
if (mPictureSizes.sizes(mAspectRatio) == null) {
pictureSize = size;
} else {
// Largest picture size in this ratio
pictureSize = mPictureSizes.sizes(mAspectRatio).last();
}

if (mShowingPreview) {
mCamera.stopPreview();
}

// Always re-apply camera parameters
mCameraParameters.setPreviewSize(size.getWidth(), size.getHeight());
mCameraParameters.setPictureSize(pictureSize.getWidth(), pictureSize.getHeight());
mCameraParameters.setRotation(calcCameraRotation(mDisplayOrientation));
Expand Down