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