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 {@link CarUiRecyclerView} example with placeholder data. 27 */ 28 public class CarUiRecyclerViewSamples extends AbstractSampleActivity { 29 30 private static final int DATA_TO_GENERATE = 15; 31 32 private final ArrayList<String> mData = new ArrayList<>(); 33 34 @Override onCreate(Bundle savedInstanceState)35 protected void onCreate(Bundle savedInstanceState) { 36 super.onCreate(savedInstanceState); 37 Utils.onActivityCreateSetTheme(this); 38 setContentView(R.layout.paged_recycler_view_samples); 39 CarUiRecyclerView recyclerView = findViewById(R.id.list); 40 RecyclerViewAdapter adapter = new RecyclerViewAdapter(generatePlaceholderData()); 41 recyclerView.setAdapter(adapter); 42 } 43 generatePlaceholderData()44 private ArrayList<String> generatePlaceholderData() { 45 for (int i = 0; i <= DATA_TO_GENERATE; i++) { 46 mData.add("data" + i); 47 } 48 return mData; 49 } 50 } 51