1633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko/*
2633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko * Copyright (C) 2017 The Android Open Source Project
3633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko *
4633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko * Licensed under the Apache License, Version 2.0 (the "License");
5633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko * you may not use this file except in compliance with the License.
6633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko * You may obtain a copy of the License at
7633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko *
8633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko *      http://www.apache.org/licenses/LICENSE-2.0
9633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko *
10633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko * Unless required by applicable law or agreed to in writing, software
11633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko * distributed under the License is distributed on an "AS IS" BASIS,
12633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko * See the License for the specific language governing permissions and
14633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko * limitations under the License.
15633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko */
16633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
17633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalkopackage com.android.tv.menu;
18633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
19633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalkoimport android.support.annotation.NonNull;
20633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalkoimport com.android.tv.R;
210cc0713c1bf8027642987b750b80217569d2932aLive Channels Teamimport com.android.tv.data.api.Channel;
22633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
2395961816a768da387f0b5523cf4363ace2044089Nick Chalko/** A class for the items in channels row. */
24633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalkopublic class ChannelsRowItem {
25633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    /** The item ID for guide item */
26633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public static final int GUIDE_ITEM_ID = -1;
27633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    /** The item ID for setup item */
28633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public static final int SETUP_ITEM_ID = -2;
29633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    /** The item ID for DVR item */
30633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public static final int DVR_ITEM_ID = -3;
31633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    /** The item ID for app link item */
32633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public static final int APP_LINK_ITEM_ID = -4;
33633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
34633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    /** The item which represents the guide. */
35633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public static final ChannelsRowItem GUIDE_ITEM =
36633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko            new ChannelsRowItem(GUIDE_ITEM_ID, R.layout.menu_card_guide);
37633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    /** The item which represents the setup. */
38633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public static final ChannelsRowItem SETUP_ITEM =
39633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko            new ChannelsRowItem(SETUP_ITEM_ID, R.layout.menu_card_setup);
40633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    /** The item which represents the DVR. */
41633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public static final ChannelsRowItem DVR_ITEM =
42633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko            new ChannelsRowItem(DVR_ITEM_ID, R.layout.menu_card_dvr);
43633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    /** The item which represents the app link. */
44633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public static final ChannelsRowItem APP_LINK_ITEM =
45633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko            new ChannelsRowItem(APP_LINK_ITEM_ID, R.layout.menu_card_app_link);
46633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
47633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    private final long mItemId;
48633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    @NonNull private Channel mChannel;
49633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    private final int mLayoutId;
50633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
51633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public ChannelsRowItem(@NonNull Channel channel, int layoutId) {
52633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko        this(channel.getId(), layoutId);
53633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko        mChannel = channel;
54633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    }
55633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
56633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    private ChannelsRowItem(long itemId, int layoutId) {
57633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko        mItemId = itemId;
58633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko        mLayoutId = layoutId;
59633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    }
60633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
6195961816a768da387f0b5523cf4363ace2044089Nick Chalko    /** Returns the channel for this item. */
62633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    @NonNull
63633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public Channel getChannel() {
64633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko        return mChannel;
65633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    }
66633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
6795961816a768da387f0b5523cf4363ace2044089Nick Chalko    /** Sets the channel. */
68633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public void setChannel(@NonNull Channel channel) {
69633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko        mChannel = channel;
70633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    }
71633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
7295961816a768da387f0b5523cf4363ace2044089Nick Chalko    /** Returns the layout resource ID to represent this item. */
73633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public int getLayoutId() {
74633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko        return mLayoutId;
75633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    }
76633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
7795961816a768da387f0b5523cf4363ace2044089Nick Chalko    /** Returns the unique ID for this item. */
78633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public long getItemId() {
79633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko        return mItemId;
80633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    }
81633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko
82633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    @Override
83633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    public String toString() {
84633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko        return "ChannelsRowItem{"
8595961816a768da387f0b5523cf4363ace2044089Nick Chalko                + "itemId="
8695961816a768da387f0b5523cf4363ace2044089Nick Chalko                + mItemId
8795961816a768da387f0b5523cf4363ace2044089Nick Chalko                + ", layoutId="
8895961816a768da387f0b5523cf4363ace2044089Nick Chalko                + mLayoutId
8995961816a768da387f0b5523cf4363ace2044089Nick Chalko                + ", channel="
9095961816a768da387f0b5523cf4363ace2044089Nick Chalko                + mChannel
9195961816a768da387f0b5523cf4363ace2044089Nick Chalko                + "}";
92633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko    }
93633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalko}
94