1 /* 2 * Copyright (C) 2014 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.settings.dialog.old; 18 19 import android.os.Bundle; 20 21 import java.util.ArrayList; 22 23 /** 24 * ************************* 25 * DO NOT ADD LOGIC HERE! 26 * ************************* 27 * This is a wrapper for {@link BaseActionFragment}. Place your logic in 28 * there and call the function from here 29 */ 30 public class ActionFragment extends ScrollAdapterFragment implements ActionAdapter.Listener, 31 ActionAdapter.OnFocusListener, ActionAdapter.OnKeyListener, LiteFragment { 32 33 private final BaseActionFragment mBase = new BaseActionFragment(this); 34 newInstance(ArrayList<Action> actions)35 public static ActionFragment newInstance(ArrayList<Action> actions) { 36 return newInstance(actions, null); 37 } 38 newInstance(ArrayList<Action> actions, String name)39 public static ActionFragment newInstance(ArrayList<Action> actions, String name) { 40 ActionFragment fragment = new ActionFragment(); 41 fragment.setArguments(BaseActionFragment.buildArgs(actions, name)); 42 return fragment; 43 } 44 newInstance(ArrayList<Action> actions, int index)45 public static ActionFragment newInstance(ArrayList<Action> actions, int index) { 46 ActionFragment fragment = new ActionFragment(); 47 fragment.setArguments(BaseActionFragment.buildArgs(actions, index)); 48 return fragment; 49 } 50 newInstance(ArrayList<Action> actions, String name, int index)51 public static ActionFragment newInstance(ArrayList<Action> actions, String name, int index) { 52 ActionFragment fragment = new ActionFragment(); 53 fragment.setArguments(BaseActionFragment.buildArgs(actions, name, index)); 54 return fragment; 55 } 56 ActionFragment()57 public ActionFragment() { 58 super(); 59 super.setBaseScrollAdapterFragment(mBase); 60 } 61 62 @Override onCreate(Bundle savedInstanceState)63 public void onCreate(Bundle savedInstanceState) { 64 super.onCreate(savedInstanceState); 65 mBase.onCreate(savedInstanceState); 66 } 67 68 @Override onResume()69 public void onResume() { 70 super.onResume(); 71 mBase.onResume(); 72 } 73 74 @Override onSaveInstanceState(Bundle outState)75 public void onSaveInstanceState(Bundle outState) { 76 super.onSaveInstanceState(outState); 77 mBase.onSaveInstanceState(outState); 78 } 79 80 @Override onActionClicked(Action action)81 public void onActionClicked(Action action) { 82 mBase.onActionClicked(action); 83 } 84 85 @Override onActionFocused(Action action)86 public void onActionFocused(Action action) { 87 mBase.onActionFocused(action); 88 } 89 90 @Override onActionSelect(Action action)91 public void onActionSelect(Action action) { 92 mBase.onActionSelect(action); 93 } 94 95 @Override onActionUnselect(Action action)96 public void onActionUnselect(Action action) { 97 mBase.onActionUnselect(action); 98 } 99 setListener(ActionAdapter.Listener listener)100 public void setListener(ActionAdapter.Listener listener) { 101 mBase.setListener(listener); 102 } 103 hasListener()104 public boolean hasListener() { 105 return mBase.hasListener(); 106 } 107 getName()108 public String getName() { 109 return mBase.getName(); 110 } 111 } 112