Search in sources :

Example 1 with Media

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);
    }
}
Also used : Movie(butter.droid.provider.base.model.Movie) Media(butter.droid.provider.base.model.Media) IOException(java.io.IOException)

Example 2 with Media

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);
    }
}
Also used : Media(butter.droid.provider.base.model.Media)

Example 3 with Media

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);
    }
}
Also used : Clip(butter.droid.provider.base.model.Clip) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Media(butter.droid.provider.base.model.Media) StreamInfo(butter.droid.base.providers.media.model.StreamInfo)

Example 4 with Media

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);
        }
    }
}
Also used : Context(android.content.Context) Media(butter.droid.provider.base.model.Media)

Example 5 with Media

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);
    }
}
Also used : Episode(butter.droid.provider.base.model.Episode) Media(butter.droid.provider.base.model.Media) Show(butter.droid.provider.base.model.Show) IOException(java.io.IOException)

Aggregations

Media (butter.droid.provider.base.model.Media)10 MediaWrapper (butter.droid.base.providers.media.model.MediaWrapper)4 StreamInfo (butter.droid.base.providers.media.model.StreamInfo)3 Clip (butter.droid.provider.base.model.Clip)3 Uri (android.net.Uri)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Context (android.content.Context)1 Bitmap (android.graphics.Bitmap)1 Drawable (android.graphics.drawable.Drawable)1 AppBarLayout (android.support.design.widget.AppBarLayout)1 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)1 Palette (android.support.v7.graphics.Palette)1 Episode (butter.droid.provider.base.model.Episode)1 Movie (butter.droid.provider.base.model.Movie)1 Show (butter.droid.provider.base.model.Show)1 Target (com.squareup.picasso.Target)1