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();
}
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());
}
}
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());
}
}
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);
}
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");
}
}
}
Aggregations