diff options
author | Nick Chalko <nchalko@google.com> | 2017-10-03 10:16:37 -0700 |
---|---|---|
committer | Nick Chalko <nchalko@google.com> | 2017-10-04 13:48:13 +0000 |
commit | 6ebde20b03db4c0d57f67acaac11832b610b966b (patch) | |
tree | d31e2adc1f9cce4f27ca07d30bee921032e33a3c /src/com/android/tv/data/BaseProgram.java | |
parent | ee027a576ddebaf1ae739219be01b0240b15f80c (diff) | |
download | TV-6ebde20b03db4c0d57f67acaac11832b610b966b.tar.gz |
Sync to match Live Channels 1.15(ncis)oreo-mr1-dev
aka ub-tv-dev at a73a150bb7d0d1ce867ef980c6ac8411899d40ad
Bug: 64021596
Change-Id: I7c544fd15e2c58784f8babc31877ad0dfeebb4c0
(cherry picked from commit 633eb826b8c97731dfc5ef12c7bf78a63734275d)
Diffstat (limited to 'src/com/android/tv/data/BaseProgram.java')
-rw-r--r-- | src/com/android/tv/data/BaseProgram.java | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/com/android/tv/data/BaseProgram.java b/src/com/android/tv/data/BaseProgram.java index f420de02..4e36c80a 100644 --- a/src/com/android/tv/data/BaseProgram.java +++ b/src/com/android/tv/data/BaseProgram.java @@ -17,12 +17,17 @@ package com.android.tv.data; import android.content.Context; +import android.media.tv.TvContentRating; +import android.support.annotation.Nullable; +import android.text.TextUtils; + +import com.android.tv.R; import java.util.Comparator; /** * Base class for {@link com.android.tv.data.Program} and - * {@link com.android.tv.dvr.RecordedProgram}. + * {@link com.android.tv.dvr.data.RecordedProgram}. */ public abstract class BaseProgram { /** @@ -94,14 +99,29 @@ public abstract class BaseProgram { abstract public String getTitle(); /** - * Returns the program's title withe its season and episode number. + * Returns the episode title. */ - abstract public String getTitleWithEpisodeNumber(Context context); + abstract public String getEpisodeTitle(); /** * Returns the displayed title of the program episode. */ - abstract public String getEpisodeDisplayTitle(Context context); + public String getEpisodeDisplayTitle(Context context) { + if (!TextUtils.isEmpty(getEpisodeNumber())) { + String episodeTitle = getEpisodeTitle() == null ? "" : getEpisodeTitle(); + if (TextUtils.equals(getSeasonNumber(), "0")) { + // Do not show "S0: ". + return String.format(context.getResources().getString( + R.string.display_episode_title_format_no_season_number), + getEpisodeNumber(), episodeTitle); + } else { + return String.format(context.getResources().getString( + R.string.display_episode_title_format), + getSeasonNumber(), getEpisodeNumber(), episodeTitle); + } + } + return getEpisodeTitle(); + } /** * Returns the description of the program. @@ -158,6 +178,10 @@ public abstract class BaseProgram { */ abstract public int[] getCanonicalGenreIds(); + /** Returns the array of content ratings. */ + @Nullable + abstract public TvContentRating[] getContentRatings(); + /** * Returns channel's ID of the program. */ @@ -169,6 +193,13 @@ public abstract class BaseProgram { abstract public boolean isValid(); /** + * Checks whether the program is episodic or not. + */ + public boolean isEpisodic() { + return getSeriesId() != null; + } + + /** * Generates the series ID for the other inputs than the tuner TV input. */ public static String generateSeriesId(String packageName, String title) { |