aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/dvr/ui/browse/DetailsContent.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/tv/dvr/ui/browse/DetailsContent.java')
-rw-r--r--src/com/android/tv/dvr/ui/browse/DetailsContent.java172
1 files changed, 92 insertions, 80 deletions
diff --git a/src/com/android/tv/dvr/ui/browse/DetailsContent.java b/src/com/android/tv/dvr/ui/browse/DetailsContent.java
index c1fa05d7..cba6293b 100644
--- a/src/com/android/tv/dvr/ui/browse/DetailsContent.java
+++ b/src/com/android/tv/dvr/ui/browse/DetailsContent.java
@@ -20,18 +20,15 @@ import android.content.Context;
import android.media.tv.TvContract;
import android.support.annotation.Nullable;
import android.text.TextUtils;
-
import com.android.tv.R;
-import com.android.tv.TvApplication;
-import com.android.tv.data.Channel;
+import com.android.tv.TvSingletons;
+import com.android.tv.data.api.Channel;
import com.android.tv.dvr.data.RecordedProgram;
import com.android.tv.dvr.data.ScheduledRecording;
import com.android.tv.dvr.data.SeriesRecording;
import com.android.tv.dvr.ui.DvrUiHelper;
-/**
- * A class for details content.
- */
+/** A class for details content. */
class DetailsContent {
/** Constant for invalid time. */
public static final long INVALID_TIME = -1;
@@ -44,8 +41,8 @@ class DetailsContent {
private String mBackgroundImageUri;
private boolean mUsingChannelLogo;
- static DetailsContent createFromRecordedProgram(Context context,
- RecordedProgram recordedProgram) {
+ static DetailsContent createFromRecordedProgram(
+ Context context, RecordedProgram recordedProgram) {
return new DetailsContent.Builder()
.setChannelId(recordedProgram.getChannelId())
.setProgramTitle(recordedProgram.getTitle())
@@ -53,32 +50,72 @@ class DetailsContent {
.setEpisodeNumber(recordedProgram.getEpisodeNumber())
.setStartTimeUtcMillis(recordedProgram.getStartTimeUtcMillis())
.setEndTimeUtcMillis(recordedProgram.getEndTimeUtcMillis())
- .setDescription(TextUtils.isEmpty(recordedProgram.getLongDescription())
- ? recordedProgram.getDescription() : recordedProgram.getLongDescription())
+ .setDescription(
+ TextUtils.isEmpty(recordedProgram.getLongDescription())
+ ? recordedProgram.getDescription()
+ : recordedProgram.getLongDescription())
.setPosterArtUri(recordedProgram.getPosterArtUri())
.setThumbnailUri(recordedProgram.getThumbnailUri())
.build(context);
}
- static DetailsContent createFromSeriesRecording(Context context,
- SeriesRecording seriesRecording) {
+ static DetailsContent createFromSeriesRecording(
+ Context context, SeriesRecording seriesRecording) {
return new DetailsContent.Builder()
.setChannelId(seriesRecording.getChannelId())
.setTitle(seriesRecording.getTitle())
- .setDescription(TextUtils.isEmpty(seriesRecording.getLongDescription())
- ? seriesRecording.getDescription() : seriesRecording.getLongDescription())
+ .setDescription(
+ TextUtils.isEmpty(seriesRecording.getLongDescription())
+ ? seriesRecording.getDescription()
+ : seriesRecording.getLongDescription())
.setPosterArtUri(seriesRecording.getPosterUri())
.setThumbnailUri(seriesRecording.getPhotoUri())
.build(context);
}
- static DetailsContent createFromScheduledRecording(Context context,
- ScheduledRecording scheduledRecording) {
- Channel channel = TvApplication.getSingletons(context).getChannelDataManager()
- .getChannel(scheduledRecording.getChannelId());
- String description = !TextUtils.isEmpty(scheduledRecording.getProgramDescription()) ?
- scheduledRecording.getProgramDescription()
- : scheduledRecording.getProgramLongDescription();
+ static DetailsContent createFromScheduledRecording(
+ Context context, ScheduledRecording scheduledRecording) {
+ Channel channel =
+ TvSingletons.getSingletons(context)
+ .getChannelDataManager()
+ .getChannel(scheduledRecording.getChannelId());
+ String description =
+ !TextUtils.isEmpty(scheduledRecording.getProgramDescription())
+ ? scheduledRecording.getProgramDescription()
+ : scheduledRecording.getProgramLongDescription();
+ if (TextUtils.isEmpty(description)) {
+ description = channel != null ? channel.getDescription() : null;
+ }
+ return new DetailsContent.Builder()
+ .setChannelId(scheduledRecording.getChannelId())
+ .setProgramTitle(scheduledRecording.getProgramTitle())
+ .setSeasonNumber(scheduledRecording.getSeasonNumber())
+ .setEpisodeNumber(scheduledRecording.getEpisodeNumber())
+ .setStartTimeUtcMillis(scheduledRecording.getStartTimeMs())
+ .setEndTimeUtcMillis(scheduledRecording.getEndTimeMs())
+ .setDescription(description)
+ .setPosterArtUri(scheduledRecording.getProgramPosterArtUri())
+ .setThumbnailUri(scheduledRecording.getProgramThumbnailUri())
+ .build(context);
+ }
+
+ static DetailsContent createFromFailedScheduledRecording(
+ Context context, ScheduledRecording scheduledRecording, String errMsg) {
+ Channel channel =
+ TvSingletons.getSingletons(context)
+ .getChannelDataManager()
+ .getChannel(scheduledRecording.getChannelId());
+ String description;
+ if (scheduledRecording.getState() == ScheduledRecording.STATE_RECORDING_FAILED
+ && errMsg != null) {
+ description = errMsg
+ + " (Error code: " + scheduledRecording.getFailedReason() + ")";
+ } else {
+ description =
+ !TextUtils.isEmpty(scheduledRecording.getProgramDescription())
+ ? scheduledRecording.getProgramDescription()
+ : scheduledRecording.getProgramLongDescription();
+ }
if (TextUtils.isEmpty(description)) {
description = channel != null ? channel.getDescription() : null;
}
@@ -95,60 +132,44 @@ class DetailsContent {
.build(context);
}
- private DetailsContent() { }
+ private DetailsContent() {}
- /**
- * Returns title.
- */
+ /** Returns title. */
public CharSequence getTitle() {
return mTitle;
}
- /**
- * Returns start time.
- */
+ /** Returns start time. */
public long getStartTimeUtcMillis() {
return mStartTimeUtcMillis;
}
- /**
- * Returns end time.
- */
+ /** Returns end time. */
public long getEndTimeUtcMillis() {
return mEndTimeUtcMillis;
}
- /**
- * Returns description.
- */
+ /** Returns description. */
public String getDescription() {
return mDescription;
}
- /**
- * Returns Logo image URI as a String.
- */
+ /** Returns Logo image URI as a String. */
public String getLogoImageUri() {
return mLogoImageUri;
}
- /**
- * Returns background image URI as a String.
- */
+ /** Returns background image URI as a String. */
public String getBackgroundImageUri() {
return mBackgroundImageUri;
}
- /**
- * Returns if image URIs are from its channels' logo.
- */
+ /** Returns if image URIs are from its channels' logo. */
public boolean isUsingChannelLogo() {
return mUsingChannelLogo;
}
- /**
- * Copies other details content.
- */
+ /** Copies other details content. */
public void copyFrom(DetailsContent other) {
if (this == other) {
return;
@@ -162,9 +183,7 @@ class DetailsContent {
mUsingChannelLogo = other.mUsingChannelLogo;
}
- /**
- * A class for building details content.
- */
+ /** A class for building details content. */
public static final class Builder {
private final DetailsContent mDetailsContent;
@@ -181,49 +200,37 @@ class DetailsContent {
mDetailsContent.mEndTimeUtcMillis = INVALID_TIME;
}
- /**
- * Sets title.
- */
+ /** Sets title. */
public Builder setTitle(CharSequence title) {
mDetailsContent.mTitle = title;
return this;
}
- /**
- * Sets start time.
- */
+ /** Sets start time. */
public Builder setStartTimeUtcMillis(long startTimeUtcMillis) {
mDetailsContent.mStartTimeUtcMillis = startTimeUtcMillis;
return this;
}
- /**
- * Sets end time.
- */
+ /** Sets end time. */
public Builder setEndTimeUtcMillis(long endTimeUtcMillis) {
mDetailsContent.mEndTimeUtcMillis = endTimeUtcMillis;
return this;
}
- /**
- * Sets description.
- */
+ /** Sets description. */
public Builder setDescription(String description) {
mDetailsContent.mDescription = description;
return this;
}
- /**
- * Sets logo image URI as a String.
- */
+ /** Sets logo image URI as a String. */
public Builder setLogoImageUri(String logoImageUri) {
mDetailsContent.mLogoImageUri = logoImageUri;
return this;
}
- /**
- * Sets background image URI as a String.
- */
+ /** Sets background image URI as a String. */
public Builder setBackgroundImageUri(String backgroundImageUri) {
mDetailsContent.mBackgroundImageUri = backgroundImageUri;
return this;
@@ -260,12 +267,18 @@ class DetailsContent {
}
private void createStyledTitle(Context context, Channel channel) {
- CharSequence title = DvrUiHelper.getStyledTitleWithEpisodeNumber(context,
- mProgramTitle, mSeasonNumber, mEpisodeNumber,
- R.style.text_appearance_card_view_episode_number);
+ CharSequence title =
+ DvrUiHelper.getStyledTitleWithEpisodeNumber(
+ context,
+ mProgramTitle,
+ mSeasonNumber,
+ mEpisodeNumber,
+ R.style.text_appearance_card_view_episode_number);
if (TextUtils.isEmpty(title)) {
- mDetailsContent.mTitle = channel != null ? channel.getDisplayName()
- : context.getResources().getString(R.string.no_program_information);
+ mDetailsContent.mTitle =
+ channel != null
+ ? channel.getDisplayName()
+ : context.getResources().getString(R.string.no_program_information);
} else {
mDetailsContent.mTitle = title;
}
@@ -288,20 +301,19 @@ class DetailsContent {
mDetailsContent.mBackgroundImageUri = mThumbnailUri;
}
if (TextUtils.isEmpty(mDetailsContent.mLogoImageUri) && channel != null) {
- String channelLogoUri = TvContract.buildChannelLogoUri(channel.getId())
- .toString();
+ String channelLogoUri = TvContract.buildChannelLogoUri(channel.getId()).toString();
mDetailsContent.mLogoImageUri = channelLogoUri;
mDetailsContent.mBackgroundImageUri = channelLogoUri;
mDetailsContent.mUsingChannelLogo = true;
}
}
- /**
- * Builds details content.
- */
+ /** Builds details content. */
public DetailsContent build(Context context) {
- Channel channel = TvApplication.getSingletons(context).getChannelDataManager()
- .getChannel(mChannelId);
+ Channel channel =
+ TvSingletons.getSingletons(context)
+ .getChannelDataManager()
+ .getChannel(mChannelId);
if (mDetailsContent.mTitle == null) {
createStyledTitle(context, channel);
}
@@ -314,4 +326,4 @@ class DetailsContent {
return detailsContent;
}
}
-} \ No newline at end of file
+}