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