From 2dd19121fc41c57c12141047a939f0b034a149b4 Mon Sep 17 00:00:00 2001 From: YeungKC Date: Fri, 5 Jan 2018 23:50:36 +0800 Subject: [PATCH] Fix preview size selection (#133) matchRatio may get unexpected size when implementation of getSupportedPreviewSizes() decides to return values in a non-descending order. --- .../java/com/otaliastudios/cameraview/CameraController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java index 85f2b5b8..ba39b2f4 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java @@ -488,7 +488,7 @@ abstract class CameraController implements SizeSelectors.minWidth(targetMinSize.getWidth())); SizeSelector matchAll = SizeSelectors.or( SizeSelectors.and(matchRatio, matchSize), - matchRatio, // If couldn't match both, match ratio. + SizeSelectors.and(matchRatio, SizeSelectors.biggest()), // If couldn't match both, match ratio and biggest. SizeSelectors.biggest() // If couldn't match any, take the biggest. ); Size result = matchAll.select(previewSizes).get(0);