ChannelsRowItem.java revision 633eb826b8c97731dfc5ef12c7bf78a63734275d
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 17package com.android.tv.menu; 18 19import android.support.annotation.NonNull; 20import android.support.annotation.Nullable; 21 22import com.android.tv.R; 23import com.android.tv.data.Channel; 24 25/** 26 * A class for the items in channels row. 27 */ 28public class ChannelsRowItem { 29 /** The item ID for guide item */ 30 public static final int GUIDE_ITEM_ID = -1; 31 /** The item ID for setup item */ 32 public static final int SETUP_ITEM_ID = -2; 33 /** The item ID for DVR item */ 34 public static final int DVR_ITEM_ID = -3; 35 /** The item ID for app link item */ 36 public static final int APP_LINK_ITEM_ID = -4; 37 38 /** The item which represents the guide. */ 39 public static final ChannelsRowItem GUIDE_ITEM = 40 new ChannelsRowItem(GUIDE_ITEM_ID, R.layout.menu_card_guide); 41 /** The item which represents the setup. */ 42 public static final ChannelsRowItem SETUP_ITEM = 43 new ChannelsRowItem(SETUP_ITEM_ID, R.layout.menu_card_setup); 44 /** The item which represents the DVR. */ 45 public static final ChannelsRowItem DVR_ITEM = 46 new ChannelsRowItem(DVR_ITEM_ID, R.layout.menu_card_dvr); 47 /** The item which represents the app link. */ 48 public static final ChannelsRowItem APP_LINK_ITEM = 49 new ChannelsRowItem(APP_LINK_ITEM_ID, R.layout.menu_card_app_link); 50 51 private final long mItemId; 52 @NonNull private Channel mChannel; 53 private final int mLayoutId; 54 55 public ChannelsRowItem(@NonNull Channel channel, int layoutId) { 56 this(channel.getId(), layoutId); 57 mChannel = channel; 58 } 59 60 private ChannelsRowItem(long itemId, int layoutId) { 61 mItemId = itemId; 62 mLayoutId = layoutId; 63 } 64 65 /** 66 * Returns the channel for this item. 67 */ 68 @NonNull 69 public Channel getChannel() { 70 return mChannel; 71 } 72 73 /** 74 * Sets the channel. 75 */ 76 public void setChannel(@NonNull Channel channel) { 77 mChannel = channel; 78 } 79 80 /** 81 * Returns the layout resource ID to represent this item. 82 */ 83 public int getLayoutId() { 84 return mLayoutId; 85 } 86 87 /** 88 * Returns the unique ID for this item. 89 */ 90 public long getItemId() { 91 return mItemId; 92 } 93 94 @Override 95 public String toString() { 96 return "ChannelsRowItem{" 97 + "itemId=" + mItemId 98 + ", layoutId=" + mLayoutId 99 + ", channel=" + mChannel + "}"; 100 } 101} 102