1 package com.android.tv.twopanelsettings.slices;
2 
3 import android.content.Context;
4 import android.util.AttributeSet;
5 
6 import androidx.preference.SeekBarPreference;
7 import androidx.slice.core.SliceActionImpl;
8 
9 /**
10  * Slices version of SeekBarPreference.
11  */
12 public class SliceSeekbarPreference extends SeekBarPreference implements HasSliceAction {
13     private int mActionId;
14     protected SliceActionImpl mAction;
15     private SliceActionImpl mFollowupSliceAction;
16 
SliceSeekbarPreference(Context context, SliceActionImpl action, int min, int max, int value)17     public SliceSeekbarPreference(Context context, SliceActionImpl action, int min, int max,
18             int value) {
19         super(context);
20         mAction = action;
21         update(min, max, value);
22     }
23 
SliceSeekbarPreference(Context context, AttributeSet attrs, SliceActionImpl action, int min, int max, int value)24     public SliceSeekbarPreference(Context context, AttributeSet attrs, SliceActionImpl action,
25             int min, int max, int value) {
26         super(context, attrs);
27         mAction = action;
28         update(min, max, value);
29     }
30 
31     @Override
getActionId()32     public int getActionId() {
33         return mActionId;
34     }
35 
36     @Override
setActionId(int actionId)37     public void setActionId(int actionId) {
38         mActionId = actionId;
39     }
40 
SliceSeekbarPreference(Context context)41     public SliceSeekbarPreference(Context context) {
42         super(context);
43     }
44 
SliceSeekbarPreference(Context context, AttributeSet attrs)45     public SliceSeekbarPreference(Context context, AttributeSet attrs) {
46         super(context, attrs);
47     }
48 
49     @Override
getSliceAction()50     public SliceActionImpl getSliceAction() {
51         return mAction;
52     }
53 
54     @Override
setSliceAction(SliceActionImpl sliceAction)55     public void setSliceAction(SliceActionImpl sliceAction) {
56         mAction = sliceAction;
57     }
58 
59     @Override
getFollowupSliceAction()60     public SliceActionImpl getFollowupSliceAction() {
61         return mFollowupSliceAction;
62     }
63 
64     @Override
setFollowupSliceAction(SliceActionImpl sliceAction)65     public void setFollowupSliceAction(SliceActionImpl sliceAction) {
66         mFollowupSliceAction = sliceAction;
67     }
68 
update(int min, int max, int value)69     private void update(int min, int max, int value) {
70         this.setMin(min);
71         this.setMax(max);
72         this.setValue(value);
73     }
74 }
75