1 /*
2  * Copyright (C) 2019 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.themeplayground;
18 
19 import android.os.Bundle;
20 
21 import com.android.car.ui.recyclerview.CarUiRecyclerView;
22 
23 import java.util.ArrayList;
24 
25 /**
26  * Activity that shows PagedRecyclerView example with dummy data.
27  */
28 public class CarUiRecyclerViewSamples extends AbstractSampleActivity {
29 
30     private final ArrayList<String> mData = new ArrayList<>();
31     private final int mDataToGenerate = 15;
32 
33     @Override
onCreate(Bundle savedInstanceState)34     protected void onCreate(Bundle savedInstanceState) {
35         super.onCreate(savedInstanceState);
36         Utils.onActivityCreateSetTheme(this);
37         setContentView(R.layout.paged_recycler_view_samples);
38         CarUiRecyclerView recyclerView = findViewById(R.id.list);
39         RecyclerViewAdapter adapter = new RecyclerViewAdapter(generateDummyData());
40         recyclerView.setAdapter(adapter);
41     }
42 
generateDummyData()43     private ArrayList<String> generateDummyData() {
44         for (int i = 0; i <= mDataToGenerate; i++) {
45             mData.add("data" + i);
46         }
47         return mData;
48     }
49 }
50