soft fix for mismatch preview/capture aspect ratios

pull/1/head
Dylan McIntyre 8 years ago
parent fbb08c7bdd
commit 3bf1a665e7
  1. 8
      camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java
  2. 4
      demo/build.gradle

@ -230,13 +230,13 @@ public class Camera1 extends CameraImpl {
mCameraParameters.getSupportedPreviewSizes(), mCameraParameters.getSupportedPreviewSizes(),
mCameraParameters.getSupportedPictureSizes() mCameraParameters.getSupportedPictureSizes()
); );
AspectRatio targetRatio = aspectRatios.last(); AspectRatio targetRatio = aspectRatios.size() > 0 ? aspectRatios.last() : null;
Iterator<Size> descendingSizes = sizes.descendingIterator(); Iterator<Size> descendingSizes = sizes.descendingIterator();
Size size; Size size;
while (descendingSizes.hasNext() && mCaptureSize == null) { while (descendingSizes.hasNext() && mCaptureSize == null) {
size = descendingSizes.next(); size = descendingSizes.next();
if (targetRatio.matches(size)) { if (targetRatio == null || targetRatio.matches(size)) {
mCaptureSize = size; mCaptureSize = size;
break; break;
} }
@ -258,13 +258,13 @@ public class Camera1 extends CameraImpl {
mCameraParameters.getSupportedPreviewSizes(), mCameraParameters.getSupportedPreviewSizes(),
mCameraParameters.getSupportedPictureSizes() mCameraParameters.getSupportedPictureSizes()
); );
AspectRatio targetRatio = aspectRatios.last(); AspectRatio targetRatio = aspectRatios.size() > 0 ? aspectRatios.last() : null;
Iterator<Size> descendingSizes = sizes.descendingIterator(); Iterator<Size> descendingSizes = sizes.descendingIterator();
Size size; Size size;
while (descendingSizes.hasNext() && mPreviewSize == null) { while (descendingSizes.hasNext() && mPreviewSize == null) {
size = descendingSizes.next(); size = descendingSizes.next();
if (targetRatio.matches(size)) { if (targetRatio == null || targetRatio.matches(size)) {
mPreviewSize = size; mPreviewSize = size;
break; break;
} }

@ -7,8 +7,8 @@ android {
applicationId "com.flurgle.camerakit.demo" applicationId "com.flurgle.camerakit.demo"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 25 targetSdkVersion 25
versionCode 1 versionCode 2
versionName "1.0" versionName "1.0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {

Loading…
Cancel
Save