• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 androidx.recyclerview.widget.LinearLayoutManager;
22 import androidx.recyclerview.widget.RecyclerView;
23 
24 import java.util.ArrayList;
25 
26 /**
27  * Activity that shows RecyclerView example with dummy data.
28  */
29 public class RecyclerViewSamples extends AbstractSampleActivity {
30 
31     private final ArrayList<String> mData = new ArrayList<>();
32     private final int mDataToGenerate = 15;
33 
34     @Override
onCreate(Bundle savedInstanceState)35     protected void onCreate(Bundle savedInstanceState) {
36         super.onCreate(savedInstanceState);
37         Utils.onActivityCreateSetTheme(this);
38         setContentView(R.layout.recycler_view_samples);
39         RecyclerView recyclerView = findViewById(R.id.list);
40         recyclerView.setLayoutManager(new LinearLayoutManager(this));
41 
42         RecyclerViewAdapter adapter = new RecyclerViewAdapter(generateDummyData());
43         recyclerView.setAdapter(adapter);
44     }
45 
generateDummyData()46     private ArrayList<String> generateDummyData() {
47         for (int i = 0; i <= mDataToGenerate; i++) {
48             mData.add("data" + i);
49         }
50         return mData;
51     }
52 
53 }
54