1 /*
2  * Copyright (C) 2017 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.car.settings.common;
18 
19 import android.os.Bundle;
20 import android.support.car.ui.PagedListView;
21 
22 import com.android.car.settings.R;
23 
24 import java.util.ArrayList;
25 
26 /**
27  * Settings page that only contain a list of items.
28  */
29 public abstract class ListSettingsActivity extends CarSettingActivity {
30 
31     private PagedListView mListView;
32     protected TypedPagedListAdapter mPagedListAdapter;
33 
34     @Override
onCreate(Bundle savedInstanceState)35     protected void onCreate(Bundle savedInstanceState) {
36         super.onCreate(savedInstanceState);
37         setContentView(R.layout.paged_list);
38 
39         mListView = (PagedListView) findViewById(R.id.list);
40         mListView.setDefaultItemDecoration(new NoDividerItemDecoration(this));
41         mListView.setDarkMode();
42         mPagedListAdapter = new TypedPagedListAdapter(this /* context */, getLineItems());
43         mListView.setAdapter(mPagedListAdapter);
44     }
45 
46     /**
47      * Gets a List of LineItems to show up in this activity.
48      */
getLineItems()49     public abstract ArrayList<TypedPagedListAdapter.LineItem> getLineItems();
50 }
51