1/* 2 * Copyright (C) 2015 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 */ 16package com.android.car.view; 17 18import android.support.v7.widget.RecyclerView; 19import android.view.View; 20import android.view.ViewStub; 21import android.widget.CheckBox; 22import android.widget.FrameLayout; 23import android.widget.ImageView; 24import android.widget.TextView; 25 26import com.android.car.stream.ui.R; 27 28/** 29 * ViewHolder for @layout/sdk_car_list_item that is used to handle the various sdk item templates 30 * @hide 31 */ 32public class CarListItemViewHolder extends RecyclerView.ViewHolder { 33 public final FrameLayout iconContainer; 34 public final ImageView icon; 35 public final TextView title; 36 public final TextView text; 37 public final ImageView rightImage; 38 public final CheckBox rightCheckbox; 39 public final TextView rightText; 40 public final FrameLayout remoteViewsContainer; 41 42 public CarListItemViewHolder(View v, int viewStubLayoutId) { 43 super(v); 44 icon = (ImageView) v.findViewById(R.id.icon); 45 iconContainer = (FrameLayout) v.findViewById(R.id.icon_container); 46 title = (TextView) v.findViewById(R.id.title); 47 text = (TextView) v.findViewById(R.id.text); 48 remoteViewsContainer = (FrameLayout) v.findViewById(R.id.remoteviews); 49 ViewStub rightStub = (ViewStub) v.findViewById(R.id.right_item); 50 if (rightStub != null) { 51 rightStub.setLayoutResource(viewStubLayoutId); 52 rightStub.setInflatedId(R.id.right_item); 53 54 if (viewStubLayoutId == R.layout.car_menu_checkbox) { 55 rightCheckbox = (CheckBox) rightStub.inflate(); 56 rightImage = null; 57 rightText = null; 58 } else if (viewStubLayoutId == R.layout.car_imageview) { 59 rightImage = (ImageView) rightStub.inflate(); 60 rightCheckbox = null; 61 rightText = null; 62 } else if (viewStubLayoutId == R.layout.car_textview) { 63 rightText = (TextView) rightStub.inflate(); 64 rightCheckbox = null; 65 rightImage = null; 66 } else { 67 rightImage = null; 68 rightCheckbox = null; 69 rightText = null; 70 } 71 } else { 72 rightImage = null; 73 rightCheckbox = null; 74 rightText = null; 75 } 76 } 77} 78