From 3bf1a665e7a374e15ead5719e49c9386a2b8a4ef Mon Sep 17 00:00:00 2001 From: Dylan McIntyre Date: Thu, 23 Feb 2017 20:05:27 -0500 Subject: [PATCH] soft fix for mismatch preview/capture aspect ratios --- .../src/main/api16/com/flurgle/camerakit/Camera1.java | 8 ++++---- demo/build.gradle | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java index 9f9a2288..82e35156 100644 --- a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java +++ b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java @@ -230,13 +230,13 @@ public class Camera1 extends CameraImpl { mCameraParameters.getSupportedPreviewSizes(), mCameraParameters.getSupportedPictureSizes() ); - AspectRatio targetRatio = aspectRatios.last(); + AspectRatio targetRatio = aspectRatios.size() > 0 ? aspectRatios.last() : null; Iterator descendingSizes = sizes.descendingIterator(); Size size; while (descendingSizes.hasNext() && mCaptureSize == null) { size = descendingSizes.next(); - if (targetRatio.matches(size)) { + if (targetRatio == null || targetRatio.matches(size)) { mCaptureSize = size; break; } @@ -258,13 +258,13 @@ public class Camera1 extends CameraImpl { mCameraParameters.getSupportedPreviewSizes(), mCameraParameters.getSupportedPictureSizes() ); - AspectRatio targetRatio = aspectRatios.last(); + AspectRatio targetRatio = aspectRatios.size() > 0 ? aspectRatios.last() : null; Iterator descendingSizes = sizes.descendingIterator(); Size size; while (descendingSizes.hasNext() && mPreviewSize == null) { size = descendingSizes.next(); - if (targetRatio.matches(size)) { + if (targetRatio == null || targetRatio.matches(size)) { mPreviewSize = size; break; } diff --git a/demo/build.gradle b/demo/build.gradle index 6b2f6330..da4c5de3 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.flurgle.camerakit.demo" minSdkVersion 19 targetSdkVersion 25 - versionCode 1 - versionName "1.0" + versionCode 2 + versionName "1.0.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes {