OSDN Git Service

Abstract logic for setting components enabled / disabled
[android-x86/packages-apps-Taskbar.git] / app / src / main / java / com / farmerbb / taskbar / fragment / SelectAppFragment.java
1 /* Copyright 2016 Braden Farmer
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 package com.farmerbb.taskbar.fragment;
17
18 import android.os.Bundle;
19 import androidx.fragment.app.Fragment;
20 import android.view.LayoutInflater;
21 import android.view.View;
22 import android.view.ViewGroup;
23 import android.widget.ListView;
24
25 import com.farmerbb.taskbar.activity.SelectAppActivity;
26
27 public class SelectAppFragment extends Fragment {
28
29     private static final String ARG_SECTION_NUMBER = "section_number";
30
31     public SelectAppFragment() {}
32
33     public static SelectAppFragment newInstance(int sectionNumber) {
34         SelectAppFragment fragment = new SelectAppFragment();
35
36         Bundle bundle = new Bundle();
37         bundle.putInt(ARG_SECTION_NUMBER, sectionNumber);
38
39         fragment.setArguments(bundle);
40         return fragment;
41     }
42
43     @Override
44     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
45         SelectAppActivity activity = (SelectAppActivity) getActivity();
46         ListView appList = new ListView(activity);
47         int type = getArguments().getInt(ARG_SECTION_NUMBER);
48
49         appList.setAdapter(activity.getAppListAdapter(type));
50
51         return appList;
52     }
53 }