Fix volume panel crashing

slider position is smaller than min value causes the exception.
Fixed by limit the position within min and max value.

Fixes: 148270968
Test: manual
Change-Id: I3d162f6d2f1035b81b1b2eb915b488084e7ea36e
This commit is contained in:
Raff Tsai
2020-01-30 08:22:09 +08:00
parent 1767201534
commit fcd9f1a870

View File

@@ -292,6 +292,14 @@ public class SliceBuilderUtils {
ListBuilder.ICON_IMAGE, sliceData.getTitle());
final Set<String> keywords = buildSliceKeywords(sliceData);
int cur = sliderController.getSliderPosition();
if (cur < sliderController.getMin()) {
cur = sliderController.getMin();
}
if (cur > sliderController.getMax()) {
cur = sliderController.getMax();
}
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
.setAccentColor(color)
.addInputRange(new InputRangeBuilder()
@@ -300,7 +308,7 @@ public class SliceBuilderUtils {
.setPrimaryAction(primaryAction)
.setMax(sliderController.getMax())
.setMin(sliderController.getMin())
.setValue(sliderController.getSliderPosition())
.setValue(cur)
.setInputAction(actionIntent))
.setKeywords(keywords)
.build();