• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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;
18 
19 import android.app.Fragment;
20 import android.support.v14.preference.PreferenceDialogFragment;
21 import android.support.v14.preference.PreferenceFragment;
22 import android.support.v17.preference.LeanbackSettingsFragment;
23 import android.support.v7.preference.Preference;
24 import android.support.v7.preference.PreferenceScreen;
25 
26 /**
27  * Base class for settings fragments. Handles launching fragments and dialogs in a reasonably
28  * generic way. Subclasses should only override onPreferenceStartInitialScreen.
29  */
30 
31 public abstract class BaseSettingsFragment extends LeanbackSettingsFragment {
32     @Override
onPreferenceStartFragment(PreferenceFragment caller, Preference pref)33     public final boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
34         final Fragment f =
35                 Fragment.instantiate(getActivity(), pref.getFragment(), pref.getExtras());
36         f.setTargetFragment(caller, 0);
37         if (f instanceof PreferenceFragment || f instanceof PreferenceDialogFragment) {
38             startPreferenceFragment(f);
39         } else {
40             startImmersiveFragment(f);
41         }
42         return true;
43     }
44 
45     @Override
onPreferenceStartScreen(PreferenceFragment caller, PreferenceScreen pref)46     public final boolean onPreferenceStartScreen(PreferenceFragment caller, PreferenceScreen pref) {
47         return false;
48     }
49 }
50