use of androidx.slice.builders.ListBuilder.InputRangeBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtils method buildSliderSlice.
private static Slice buildSliderSlice(Context context, SliceData sliceData, BasePreferenceController controller) {
final SliderPreferenceController sliderController = (SliderPreferenceController) controller;
if (sliderController.getMax() <= sliderController.getMin()) {
Log.e(TAG, "Invalid sliderController: " + sliderController.getPreferenceKey());
return null;
}
final PendingIntent actionIntent = getSliderAction(context, sliceData);
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
final IconCompat icon = getSafeIcon(context, sliceData);
@ColorInt final int color = Utils.getColorAccentDefaultColor(context);
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
final SliceAction primaryAction = SliceAction.createDeeplink(contentIntent, icon, 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().setTitle(sliceData.getTitle()).setSubtitle(subtitleText).setPrimaryAction(primaryAction).setMax(sliderController.getMax()).setMin(sliderController.getMin()).setValue(cur).setInputAction(actionIntent)).setKeywords(keywords).build();
}
Aggregations