Search in sources :

Example 6 with Media

use of butter.droid.provider.base.model.Media in project butter-android by butterproject.

the class TVLaunchActivity method navigateForward.

@Override
public void navigateForward() {
    String action = getIntent().getAction();
    Uri data = getIntent().getData();
    if (action != null && action.equals(Intent.ACTION_VIEW) && data != null) {
        String streamUrl = data.toString();
        try {
            streamUrl = URLDecoder.decode(streamUrl, "utf-8");
            final Media media = new Clip("0", streamUrl, -1, new Genre[0], -1, null, "", "", streamUrl);
            TVStreamLoadingActivity.startActivity(this, new StreamInfo(streamUrl, new MediaWrapper(media, -1), null));
            finish();
            return;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
    TVMainActivity.startActivity(this);
    finish();
}
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) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Uri(android.net.Uri)

Example 7 with Media

use of butter.droid.provider.base.model.Media in project butter-android by butterproject.

the class MediaDetailsDescriptionPresenter method onBindDescription.

@Override
protected void onBindDescription(ViewHolder viewHolder, Object item) {
    MediaWrapper itemWrapper = (MediaWrapper) item;
    if (itemWrapper != null) {
        Media media = itemWrapper.getMedia();
        viewHolder.getTitle().setText(media.getTitle());
        viewHolder.getBody().setText(media.getSynopsis());
    }
}
Also used : MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Media(butter.droid.provider.base.model.Media)

Example 8 with Media

use of butter.droid.provider.base.model.Media in project butter-android by butterproject.

the class MediaCardPresenter method onBindMediaViewHolder.

public void onBindMediaViewHolder(Presenter.ViewHolder viewHolder, MediaCardItem overview) {
    Media item = overview.getMediaWrapper().getMedia();
    final CustomImageCardView cardView = (CustomImageCardView) viewHolder.view;
    cardView.setTitleText(item.getTitle());
    // cardView.setContentText(!TextUtils.isEmpty(item.getGenres().length) ? item.getGenres() : item.getYear());
    cardView.setContentText(String.valueOf(item.getYear()));
    cardView.getMainImageView().setAlpha(1f);
    cardView.getMainImageView().setPadding(0, 0, 0, 0);
    cardView.setMainImageDimensions(cardWidth, cardHeight);
    cardView.getMainImageView().setVisibility(View.GONE);
    cardView.setCustomSelectedSwatch(null);
    if (item.getPoster() != null) {
        Target target = new Target() {

            @Override
            public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) {
                Palette.from(bitmap).maximumColorCount(16).generate(palette -> {
                    Palette.Swatch swatch = palette.getDarkMutedSwatch();
                    cardView.setCustomSelectedSwatch(swatch);
                    cardView.getMainImageView().setImageBitmap(bitmap);
                    cardView.getMainImageView().setVisibility(View.GONE);
                    AnimUtils.fadeIn(cardView.getMainImageView());
                });
            }

            @Override
            public void onBitmapFailed(Drawable errorDrawable) {
                cardView.getMainImageView().setImageResource(R.drawable.placeholder_inset);
                cardView.getMainImageView().setAlpha(0.4f);
                cardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                cardView.getMainImageView().setVisibility(View.GONE);
                AnimUtils.fadeIn(cardView.getMainImageView());
            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {
            }
        };
        // load image
        picasso.load(item.getPoster()).resize(cardWidth, cardHeight).centerCrop().into(target);
        cardView.setTarget(target);
    } else {
        cardView.getMainImageView().setImageResource(R.drawable.placeholder_inset);
        cardView.getMainImageView().setAlpha(0.4f);
        cardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        cardView.getMainImageView().setVisibility(View.GONE);
        AnimUtils.fadeIn(cardView.getMainImageView());
    }
}
Also used : Palette(android.support.v7.graphics.Palette) Target(com.squareup.picasso.Target) Bitmap(android.graphics.Bitmap) Media(butter.droid.provider.base.model.Media) Drawable(android.graphics.drawable.Drawable)

Example 9 with Media

use of butter.droid.provider.base.model.Media in project butter-android by butterproject.

the class MediaDetailActivity method initMediaLayout.

@Override
public void initMediaLayout(MediaWrapper mediaWrapper) {
    Media media = mediaWrapper.getMedia();
    getSupportActionBar().setTitle(media.getTitle());
    int color = mediaWrapper.getColor();
    if (mediaWrapper.hasColor()) {
        collapsingToolbar.setContentScrimColor(color);
        collapsingToolbar.setStatusBarScrimColor(color);
    }
    collapsingToolbar.setTitleEnabled(false);
    // Calculate toolbar scrolling variables
    int topHeight = PixelUtils.getScreenHeight(this) / 3 * 2;
    if (!isTablet) {
        if (mediaWrapper.hasColor()) {
            // noinspection ConstantConditions
            floatingActionButton.setBackgroundTintList(ColorStateList.valueOf(color));
        }
        bgImage.getLayoutParams().height = topHeight;
    } else {
        CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) scrollView.getLayoutParams();
        AppBarLayout.ScrollingViewBehavior behavior = (AppBarLayout.ScrollingViewBehavior) params.getBehavior();
        behavior.setOverlayTop(topHeight);
    }
    loadBackgroundImage(media);
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Media(butter.droid.provider.base.model.Media) AppBarLayout(android.support.design.widget.AppBarLayout)

Example 10 with Media

use of butter.droid.provider.base.model.Media in project butter-android by butterproject.

the class MainActivity method checkActions.

private void checkActions() {
    String action = getIntent().getAction();
    Uri data = getIntent().getData();
    if (action != null && action.equals(Intent.ACTION_VIEW) && data != null) {
        String streamUrl = data.toString();
        try {
            streamUrl = URLDecoder.decode(streamUrl, "UTF-8");
            // TODO: 7/29/17 Check if actual torrent
            final Media clip = new Clip("0", streamUrl, 0, new Genre[0], -1, "", "", "", streamUrl);
            StreamLoadingActivity.startActivity(this, new StreamInfo(streamUrl, new MediaWrapper(clip, -1), null));
            finish();
        } catch (UnsupportedEncodingException e) {
            // this should never happen
            Timber.d("Unknown encoding");
        }
    }
}
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) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Uri(android.net.Uri)

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