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 */ 14package android.support.v17.leanback.widget; 15 16import 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 */ 22public class HeaderItem { 23 24 private final long mId; 25 private final String mName; 26 private CharSequence mDescription; 27 private CharSequence mContentDescription; 28 29 /** 30 * Create a header item. All fields are optional. 31 */ 32 public HeaderItem(long id, String name) { 33 mId = id; 34 mName = name; 35 } 36 37 /** 38 * Create a header item. 39 */ 40 public HeaderItem(String name) { 41 this(NO_ID, name); 42 } 43 44 /** 45 * Returns a unique identifier for this item. 46 */ 47 public final long getId() { 48 return mId; 49 } 50 51 /** 52 * Returns the name of this header item. 53 */ 54 public final String getName() { 55 return mName; 56 } 57 58 /** 59 * Returns optional content description for the HeaderItem. When it is null, {@link #getName()} 60 * should be used for the content description. 61 * @return Content description for the HeaderItem. 62 */ 63 public CharSequence getContentDescription() { 64 return mContentDescription; 65 } 66 67 /** 68 * Sets optional content description for the HeaderItem. 69 * @param contentDescription Content description sets on the HeaderItem. 70 */ 71 public void setContentDescription(CharSequence contentDescription) { 72 mContentDescription = contentDescription; 73 } 74 75 /** 76 * Sets the description for the current header item. This will be visible when 77 * the row receives focus. 78 */ 79 public void setDescription(CharSequence description) { 80 this.mDescription = description; 81 } 82 83 /** 84 * Returns the description for the current row. 85 */ 86 public CharSequence getDescription() { 87 return mDescription; 88 } 89} 90