Fix preview size selection (#133)

matchRatio may get unexpected size when implementation of getSupportedPreviewSizes() decides to return values in a non-descending order.
pull/137/head
YeungKC 7 years ago committed by Mattia Iavarone
parent 1bd1816919
commit 2dd19121fc
  1. 2
      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);

Loading…
Cancel
Save