Home | History | Annotate | Download | only in list
      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 android.content.Context;
     20 
     21 import com.android.tv.data.Program;
     22 import com.android.tv.dvr.ScheduledRecording;
     23 import com.android.tv.dvr.ScheduledRecording.Builder;
     24 
     25 /**
     26  * A class for the episodic program.
     27  */
     28 public class EpisodicProgramRow extends ScheduleRow {
     29     private final String mInputId;
     30     private final Program mProgram;
     31 
     32     public EpisodicProgramRow(String inputId, Program program, ScheduledRecording recording,
     33             SchedulesHeaderRow headerRow) {
     34         super(recording, headerRow);
     35         mInputId = inputId;
     36         mProgram = program;
     37     }
     38 
     39     /**
     40      * Returns the program.
     41      */
     42     public Program getProgram() {
     43         return mProgram;
     44     }
     45 
     46     @Override
     47     public long getChannelId() {
     48         return mProgram.getChannelId();
     49     }
     50 
     51     @Override
     52     public long getStartTimeMs() {
     53         return mProgram.getStartTimeUtcMillis();
     54     }
     55 
     56     @Override
     57     public long getEndTimeMs() {
     58         return mProgram.getEndTimeUtcMillis();
     59     }
     60 
     61     @Override
     62     public Builder createNewScheduleBuilder() {
     63         return ScheduledRecording.builder(mInputId, mProgram);
     64     }
     65 
     66     @Override
     67     public String getProgramTitleWithEpisodeNumber(Context context) {
     68         return mProgram.getTitleWithEpisodeNumber(context);
     69     }
     70 
     71     @Override
     72     public String getEpisodeDisplayTitle(Context context) {
     73         return mProgram.getEpisodeDisplayTitle(context);
     74     }
     75 
     76     @Override
     77     public boolean matchSchedule(ScheduledRecording schedule) {
     78         return schedule.getType() == ScheduledRecording.TYPE_PROGRAM
     79                 && mProgram.getId() == schedule.getProgramId();
     80     }
     81 
     82     @Override
     83     public String toString() {
     84         return super.toString()
     85                 + "(inputId=" + mInputId
     86                 + ",program=" + mProgram
     87                 + ")";
     88     }
     89 }
     90