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 androidx.leanback.preference;
18 
19 import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX;
20 
21 import android.app.Fragment;
22 import android.os.Bundle;
23 import android.view.LayoutInflater;
24 import android.view.ViewGroup;
25 
26 import androidx.annotation.RestrictTo;
27 import androidx.leanback.widget.VerticalGridView;
28 import androidx.preference.PreferenceFragment;
29 import androidx.preference.PreferenceRecyclerViewAccessibilityDelegate;
30 import androidx.recyclerview.widget.RecyclerView;
31 
32 /**
33  * This fragment provides a preference fragment with leanback-style behavior, suitable for
34  * embedding into broader UI elements.
35  * @deprecated Use {@link BaseLeanbackPreferenceFragmentCompat}
36  */
37 @Deprecated
38 public abstract class BaseLeanbackPreferenceFragment extends PreferenceFragment {
39 
40     @Override
onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)41     public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
42             Bundle savedInstanceState) {
43         VerticalGridView verticalGridView = (VerticalGridView) inflater
44                 .inflate(R.layout.leanback_preferences_list, parent, false);
45         verticalGridView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_BOTH_EDGE);
46         verticalGridView.setFocusScrollStrategy(VerticalGridView.FOCUS_SCROLL_ALIGNED);
47         verticalGridView.setAccessibilityDelegateCompat(
48                 new PreferenceRecyclerViewAccessibilityDelegate(verticalGridView));
49         return verticalGridView;
50     }
51 
52     /**
53      */
54     @RestrictTo(LIBRARY_GROUP_PREFIX)
55     @Override
getCallbackFragment()56     public Fragment getCallbackFragment() {
57         return getParentFragment();
58     }
59 }
60