1// CHECKSTYLE:OFF Generated code
2/* This file is auto-generated from GuidedStepTestSupportFragment.java.  DO NOT MODIFY. */
3
4/*
5 * Copyright (C) 2016 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18package androidx.leanback.app;
19
20import android.app.Activity;
21import android.app.FragmentManager;
22import android.os.Bundle;
23import android.view.LayoutInflater;
24import android.view.View;
25import android.view.ViewGroup;
26
27import androidx.leanback.widget.GuidanceStylist.Guidance;
28import androidx.leanback.widget.GuidedAction;
29
30import java.util.HashMap;
31import java.util.List;
32
33public class GuidedStepTestFragment extends GuidedStepFragment {
34
35    private static final String KEY_TEST_NAME = "key_test_name";
36
37    private static final HashMap<String, Provider> sTestMap = new HashMap<String, Provider>();
38
39    public static class Provider {
40
41        GuidedStepTestFragment mFragment;
42
43        public void onCreate(Bundle savedInstanceState) {
44        }
45
46        public void onSaveInstanceState(Bundle outState) {
47        }
48
49        public Guidance onCreateGuidance(Bundle savedInstanceState) {
50            return new Guidance("", "", "", null);
51        }
52
53        public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
54        }
55
56        public void onCreateButtonActions(List<GuidedAction> actions, Bundle savedInstanceState) {
57        }
58
59        public void onGuidedActionClicked(GuidedAction action) {
60        }
61
62        public boolean onSubGuidedActionClicked(GuidedAction action) {
63            return true;
64        }
65
66        public void onCreateView(LayoutInflater inflater, ViewGroup container,
67                Bundle savedInstanceState, View result) {
68        }
69
70        public void onDestroyView() {
71        }
72
73        public void onDestroy() {
74        }
75
76        public void onStart() {
77        }
78
79        public void onStop() {
80        }
81
82        public void onResume() {
83        }
84
85        public void onPause() {
86        }
87
88        public void onViewStateRestored(Bundle bundle) {
89        }
90
91        public void onDetach() {
92        }
93
94        public GuidedStepTestFragment getFragment() {
95            return mFragment;
96        }
97
98        public Activity getActivity() {
99            return mFragment.getActivity();
100        }
101
102        public FragmentManager getFragmentManager() {
103            return mFragment.getFragmentManager();
104        }
105    }
106
107    public static void setupTest(String testName, Provider provider) {
108        sTestMap.put(testName, provider);
109    }
110
111    public static void clearTests() {
112        sTestMap.clear();
113    }
114
115    CharSequence mTestName;
116    Provider mProvider;
117
118    public GuidedStepTestFragment() {
119    }
120
121    public GuidedStepTestFragment(String testName) {
122        setTestName(testName);
123    }
124
125    public void setTestName(CharSequence testName) {
126        mTestName = testName;
127    }
128
129    public CharSequence getTestName() {
130        return mTestName;
131    }
132
133    @Override
134    public void onCreate(Bundle savedInstanceState) {
135        if (savedInstanceState != null) {
136            mTestName = savedInstanceState.getCharSequence(KEY_TEST_NAME, null);
137        }
138        mProvider = sTestMap.get(mTestName);
139        if (mProvider == null) {
140            throw new IllegalArgumentException("you must setupTest()");
141        }
142        mProvider.mFragment = this;
143        super.onCreate(savedInstanceState);
144        mProvider.onCreate(savedInstanceState);
145    }
146
147    @Override
148    public void onSaveInstanceState(Bundle outState) {
149        super.onSaveInstanceState(outState);
150        outState.putCharSequence(KEY_TEST_NAME, mTestName);
151        mProvider.onSaveInstanceState(outState);
152    }
153
154    @Override
155    public Guidance onCreateGuidance(Bundle savedInstanceState) {
156        Guidance g = mProvider.onCreateGuidance(savedInstanceState);
157        if (g == null) {
158            g = new Guidance("", "", "", null);
159        }
160        return g;
161    }
162
163    @Override
164    public void onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState) {
165        mProvider.onCreateActions(actions, savedInstanceState);
166    }
167
168    @Override
169    public void onCreateButtonActions(List<GuidedAction> actions, Bundle savedInstanceState) {
170        mProvider.onCreateButtonActions(actions, savedInstanceState);
171    }
172
173    @Override
174    public void onGuidedActionClicked(GuidedAction action) {
175        mProvider.onGuidedActionClicked(action);
176    }
177
178    @Override
179    public boolean onSubGuidedActionClicked(GuidedAction action) {
180        return mProvider.onSubGuidedActionClicked(action);
181    }
182
183    @Override
184    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
185        View view = super.onCreateView(inflater, container, state);
186        mProvider.onCreateView(inflater, container, state, view);
187        return view;
188    }
189
190    @Override
191    public void onDestroyView() {
192        mProvider.onDestroyView();
193        super.onDestroyView();
194    }
195
196    @Override
197    public void onDestroy() {
198        mProvider.onDestroy();
199        super.onDestroy();
200    }
201
202    @Override
203    public void onPause() {
204        mProvider.onPause();
205        super.onPause();
206    }
207
208    @Override
209    public void onResume() {
210        super.onResume();
211        mProvider.onResume();
212    }
213
214    @Override
215    public void onStart() {
216        super.onStart();
217        mProvider.onStart();
218    }
219
220    @Override
221    public void onStop() {
222        mProvider.onStop();
223        super.onStop();
224    }
225
226    @Override
227    public void onDetach() {
228        mProvider.onDetach();
229        super.onDetach();
230    }
231
232    @Override
233    public void onViewStateRestored(Bundle bundle) {
234        super.onViewStateRestored(bundle);
235        mProvider.onViewStateRestored(bundle);
236    }
237}
238
239