1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tv.twopanelsettings.slices; 18 19 import android.content.Context; 20 21 import androidx.slice.core.SliceActionImpl; 22 23 /** 24 * Slice version of RadioPreference. 25 */ 26 public class SliceRadioPreference extends RadioPreference implements HasSliceAction, HasSliceUri { 27 private int mActionId; 28 private SliceActionImpl mSliceAction; 29 private String mUri; 30 private SliceActionImpl mFollowupSliceAction; 31 SliceRadioPreference(Context context, SliceActionImpl action)32 public SliceRadioPreference(Context context, SliceActionImpl action) { 33 super(context); 34 mSliceAction = action; 35 update(); 36 } 37 38 @Override getActionId()39 public int getActionId() { 40 return mActionId; 41 } 42 43 @Override setActionId(int actionId)44 public void setActionId(int actionId) { 45 mActionId = actionId; 46 } 47 48 @Override getSliceAction()49 public SliceActionImpl getSliceAction() { 50 return mSliceAction; 51 } 52 53 @Override setSliceAction(SliceActionImpl sliceAction)54 public void setSliceAction(SliceActionImpl sliceAction) { 55 mSliceAction = sliceAction; 56 } 57 58 @Override getFollowupSliceAction()59 public SliceActionImpl getFollowupSliceAction() { 60 return mFollowupSliceAction; 61 } 62 63 @Override setFollowupSliceAction(SliceActionImpl sliceAction)64 public void setFollowupSliceAction(SliceActionImpl sliceAction) { 65 mFollowupSliceAction = sliceAction; 66 } 67 update()68 private void update() { 69 this.setChecked(mSliceAction.isChecked()); 70 } 71 72 @Override setUri(String uri)73 public void setUri(String uri) { 74 this.mUri = uri; 75 } 76 77 @Override getUri()78 public String getUri() { 79 return mUri; 80 } 81 } 82