Skip to content

Commit

Permalink
Fixed index error when previous video size no longer is a valid option.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGillsjo committed Oct 27, 2020
1 parent bab840f commit c25e4f9
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;


Expand Down Expand Up @@ -321,6 +320,16 @@ private void updatePreferenceList(ListPreference listPreference, boolean useSens
String[] stringSizes = validSizes.stream().map(Object::toString).toArray(String[]::new);
int defaultIndex = validSizes.indexOf(getSize());

// The previous choice was from the full list, this size is not present in the sensor aspect ratio list.
if (defaultIndex == -1) {
Size closestSize = CameraUtils.chooseOptimalSize(
validSizes.toArray(new Size[0]),
getSize().getWidth(),
getSize().getHeight(),
new Size(mArraySensorSize.width(), mArraySensorSize.height()));
defaultIndex = validSizes.indexOf(closestSize);
}

listPreference.setEntryValues(stringSizes);
listPreference.setEntries(stringSizes);
listPreference.setValueIndex(defaultIndex);
Expand Down

0 comments on commit c25e4f9

Please sign in to comment.