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.support.v7.widget.RecyclerView; 20 import android.view.LayoutInflater; 21 import android.view.View; 22 import android.view.ViewGroup; 23 import android.widget.TextView; 24 25 import com.android.car.settings.R; 26 27 /** 28 * Contains logic for a line item represents text only view of a title. 29 */ 30 public class SingleTextLineItem 31 extends TypedPagedListAdapter.LineItem<SingleTextLineItem.ViewHolder> { 32 private final CharSequence mTitle; 33 SingleTextLineItem(CharSequence title)34 public SingleTextLineItem(CharSequence title) { 35 mTitle = title; 36 } 37 38 @Override getType()39 public int getType() { 40 return SINGLE_TEXT_TYPE; 41 } 42 43 @Override bindViewHolder(ViewHolder viewHolder)44 public void bindViewHolder(ViewHolder viewHolder) { 45 viewHolder.titleView.setText(mTitle); 46 } 47 48 public static class ViewHolder extends RecyclerView.ViewHolder { 49 public final TextView titleView; 50 ViewHolder(View view)51 public ViewHolder(View view) { 52 super(view); 53 titleView = view.findViewById(R.id.title); 54 } 55 } 56 createViewHolder(ViewGroup parent)57 public static RecyclerView.ViewHolder createViewHolder(ViewGroup parent) { 58 return new ViewHolder(LayoutInflater.from(parent.getContext()) 59 .inflate(R.layout.single_text_line_item, parent, false)); 60 } 61 62 @Override getDesc()63 public CharSequence getDesc() { 64 return null; 65 } 66 67 @Override isExpandable()68 public boolean isExpandable() { 69 return false; 70 } 71 72 @Override isClickable()73 public boolean isClickable() { 74 return true; 75 } 76 } 77