use of butter.droid.provider.base.model.Media in project butter-android by butterproject.
the class RecommendationService method buildMovieRecommendations.
private void buildMovieRecommendations(@NonNull RecommendationBuilder builder) {
Timber.d("building movie recommendations");
try {
int count = 0;
for (Media media : movies) {
Movie movie = (Movie) media;
Timber.d("Recommendation - " + movie.getTitle());
priority--;
totalCount--;
builder.setBackgroundContentUri(RecommendationContentProvider.CONTENT_URI + URLEncoder.encode(movie.getBackdrop(), "UTF-8")).setId(totalCount).setPriority(priority).setTitle(movie.getTitle()).setDescription(movie.getSynopsis()).setImage(movie.getPoster()).build();
if (++count >= MAX_MOVIE_RECOMMENDATIONS) {
break;
}
}
} catch (IOException e) {
Timber.e("Unable to update recommendation", e);
}
}
use of butter.droid.provider.base.model.Media in project butter-android by butterproject.
the class StreamableDetailFragment method initLayout.
@Override
public void initLayout(MediaWrapper mediaWrapper) {
Media media = mediaWrapper.getMedia();
title.setText(media.getTitle());
quality.setFragmentManager(getFragmentManager());
quality.setTitle(R.string.quality);
quality.setListener((position, value) -> setQuality(position));
if (fab != null && mediaWrapper.hasColor()) {
fab.setBackgroundTintList(ColorStateList.valueOf(mediaWrapper.getColor()));
}
if (mediaWrapper.isMovie()) {
watchTrailer.setVisibility(TextUtils.isEmpty(((Movie) media).getTrailer()) ? View.GONE : View.VISIBLE);
}
if (coverImage != null) {
Picasso.with(coverImage.getContext()).load(media.getBackdrop()).into(coverImage);
}
}
use of butter.droid.provider.base.model.Media in project butter-android by butterproject.
the class VideoPlayerPresenterImpl method onCreate.
@Override
public void onCreate(final StreamInfo streamInfo, final long resumePosition, final String action, final Intent intent) {
if (Intent.ACTION_VIEW.equals(action)) {
String videoLocation = StreamInfoUtils.getActionViewVideoLocation(contentResolver, intent);
if (videoLocation != null) {
final Media media = new Clip("0", videoLocation, -1, new Genre[0], -1, "", "", "", videoLocation);
this.streamInfo = new StreamInfo(videoLocation, new MediaWrapper(media, -1), null);
this.resumePosition = intent.getLongExtra("position", 0);
view.showVideoFragment(this.streamInfo, this.resumePosition);
} else {
// TODO: 4/2/17 Show error
}
} else {
this.streamInfo = streamInfo;
this.resumePosition = resumePosition;
if (streamInfo == null) {
throw new IllegalStateException("StreamInfo has to be provided");
}
view.showVideoFragment(streamInfo, resumePosition);
}
}
use of butter.droid.provider.base.model.Media in project butter-android by butterproject.
the class MediaGridAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, int position) {
if (getItemViewType(position) == VIEW_TYPE_ITEM) {
final ViewHolder videoViewHolder = (ViewHolder) viewHolder;
final Media item = getItem(position).getMedia();
videoViewHolder.title.setText(item.getTitle());
videoViewHolder.year.setText(String.valueOf(item.getYear()));
if (!TextUtils.isEmpty(item.getPoster())) {
// TODO: 7/30/17 Do we need color information here?
final Context context = videoViewHolder.coverImage.getContext();
Picasso.with(context).load(item.getPoster()).resize(itemWidth, itemHeight).transform(DrawGradient.INSTANCE).into(videoViewHolder.coverImage);
}
}
}
use of butter.droid.provider.base.model.Media in project butter-android by butterproject.
the class RecommendationService method buildShowRecommendations.
private void buildShowRecommendations(@NonNull RecommendationBuilder builder) {
Timber.d("building show recommendations");
try {
int count = 0;
for (Media media : shows) {
Show show = (Show) media;
Timber.d("Recommendation - " + show.getTitle());
Episode latestEpisode = findLatestEpisode(show);
priority--;
totalCount--;
builder.setBackgroundContentUri(RecommendationContentProvider.CONTENT_URI + URLEncoder.encode(show.getBackdrop(), "UTF-8")).setId(totalCount).setPriority(priority).setTitle(show.getTitle()).setDescription(latestEpisode == null ? "" : getString(R.string.episode_number_format, latestEpisode.getEpisode())).setImage(show.getPoster()).build();
if (++count >= MAX_SHOW_RECOMMENDATIONS) {
break;
}
}
} catch (IOException e) {
Timber.e("Unable to update recommendation", e);
}
}
Aggregations