1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package android.support.v17.leanback.widget; 15 16 import static android.support.v17.leanback.widget.ObjectAdapter.NO_ID; 17 18 /** 19 * A header item describes the metadata of a {@link Row}, such as a category 20 * of media items. May be subclassed to add more information. 21 */ 22 public class HeaderItem { 23 24 private final long mId; 25 private final String mName; 26 private CharSequence mContentDescription; 27 28 /** 29 * Create a header item. All fields are optional. 30 */ HeaderItem(long id, String name)31 public HeaderItem(long id, String name) { 32 mId = id; 33 mName = name; 34 } 35 36 /** 37 * Create a header item. 38 */ HeaderItem(String name)39 public HeaderItem(String name) { 40 this(NO_ID, name); 41 } 42 43 /** 44 * Returns a unique identifier for this item. 45 */ getId()46 public final long getId() { 47 return mId; 48 } 49 50 /** 51 * Returns the name of this header item. 52 */ getName()53 public final String getName() { 54 return mName; 55 } 56 57 /** 58 * Returns optional content description for the HeaderItem. When it is null, {@link #getName()} 59 * should be used for the content description. 60 * @return Content description for the HeaderItem. 61 */ getContentDescription()62 public CharSequence getContentDescription() { 63 return mContentDescription; 64 } 65 66 /** 67 * Sets optional content description for the HeaderItem. 68 * @param contentDescription Content description sets on the HeaderItem. 69 */ setContentDescription(CharSequence contentDescription)70 public void setContentDescription(CharSequence contentDescription) { 71 mContentDescription = contentDescription; 72 } 73 } 74