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