1 /*
2  * Copyright (C) 2016 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.dvr.ui.list;
18 
19 import com.android.tv.data.api.Program;
20 import com.android.tv.dvr.data.SeriesRecording;
21 
22 import java.util.List;
23 
24 /** A base class for the rows for schedules' header. */
25 abstract class SchedulesHeaderRow {
26     private String mTitle;
27     private String mDescription;
28     private int mItemCount;
29 
SchedulesHeaderRow(String title, String description, int itemCount)30     public SchedulesHeaderRow(String title, String description, int itemCount) {
31         mTitle = title;
32         mItemCount = itemCount;
33         mDescription = description;
34     }
35 
36     /** Sets title. */
setTitle(String title)37     public void setTitle(String title) {
38         mTitle = title;
39     }
40 
41     /** Sets description. */
setDescription(String description)42     public void setDescription(String description) {
43         mDescription = description;
44     }
45 
46     /** Sets count of items. */
setItemCount(int itemCount)47     public void setItemCount(int itemCount) {
48         mItemCount = itemCount;
49     }
50 
51     /** Returns title. */
getTitle()52     public String getTitle() {
53         return mTitle;
54     }
55 
56     /** Returns description. */
getDescription()57     public String getDescription() {
58         return mDescription;
59     }
60 
61     /** Returns count of items. */
getItemCount()62     public int getItemCount() {
63         return mItemCount;
64     }
65 
66     /** The header row which represent the date. */
67     public static class DateHeaderRow extends SchedulesHeaderRow {
68         private long mDeadLineMs;
69 
DateHeaderRow(String title, String description, int itemCount, long deadLineMs)70         public DateHeaderRow(String title, String description, int itemCount, long deadLineMs) {
71             super(title, description, itemCount);
72             mDeadLineMs = deadLineMs;
73         }
74 
75         /** Returns the latest time of the list which belongs to the header row. */
getDeadLineMs()76         public long getDeadLineMs() {
77             return mDeadLineMs;
78         }
79     }
80 
81     /** The header row which represent the series recording. */
82     public static class SeriesRecordingHeaderRow extends SchedulesHeaderRow {
83         private SeriesRecording mSeriesRecording;
84         private List<Program> mPrograms;
85 
SeriesRecordingHeaderRow( String title, String description, int itemCount, SeriesRecording series, List<Program> programs)86         public SeriesRecordingHeaderRow(
87                 String title,
88                 String description,
89                 int itemCount,
90                 SeriesRecording series,
91                 List<Program> programs) {
92             super(title, description, itemCount);
93             mSeriesRecording = series;
94             mPrograms = programs;
95         }
96 
97         /** Returns the list of programs which belong to the series. */
getPrograms()98         public List<Program> getPrograms() {
99             return mPrograms;
100         }
101 
102         /** Returns the series recording, it is for series schedules list. */
getSeriesRecording()103         public SeriesRecording getSeriesRecording() {
104             return mSeriesRecording;
105         }
106 
107         /** Sets the series recording. */
setSeriesRecording(SeriesRecording seriesRecording)108         public void setSeriesRecording(SeriesRecording seriesRecording) {
109             mSeriesRecording = seriesRecording;
110         }
111     }
112 }
113