Search in sources :

Example 21 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper 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 22 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper in project butter-android by butterproject.

the class TrailerPlayerFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    String uri = args.getString(ARG_URI);
    MediaWrapper media = args.getParcelable(ARG_MEDIA);
    presenter.onCreate(media, uri, getResumePosition(savedInstanceState));
}
Also used : MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Bundle(android.os.Bundle)

Example 23 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper in project butter-android by butterproject.

the class BaseMediaListFragment method onItemClick.

@Override
public void onItemClick(View view, final int position) {
    final MediaWrapper media = adapter.getItem(position);
    presenter.onMediaItemClicked(media);
// TODO: 6/25/17 Colors
// RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
// ImageView coverImage = ((MediaGridAdapter.ViewHolder) holder).getCoverImage();
// 
// if (coverImage.getDrawable() == null) {
// showLoadingDialog(position);
// return;
// }
// //
// Bitmap cover = ((BitmapDrawable) coverImage.getDrawable()).getBitmap();
// Palette.from(cover)
// .maximumColorCount(5)
// .generate(palette -> {
// int vibrantColor = palette.getVibrantColor(Color.TRANSPARENT);
// int paletteColor;
// if (vibrantColor == Color.TRANSPARENT) {
// paletteColor = palette.getMutedColor(ContextCompat.getColor(getContext(), R.color.primary));
// } else {
// paletteColor = vibrantColor;
// }
// media.setColor(paletteColor);
// showLoadingDialog(position);
// });
}
Also used : MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper)

Example 24 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper in project butter-android by butterproject.

the class BaseMediaListPresenterImpl method loadNextPage.

@Override
public void loadNextPage(@Nullable String endCursor) {
    cancelListCall();
    if (items.isEmpty()) {
        updateLoadingMessage(getLoadingMessage());
        showLoading();
    }
    providerManager.getMediaProvider(providerId).items(filter, new Pager(endCursor)).flatMap(w -> Single.zip(Single.just(w.getPaging()), Observable.fromIterable(w.getMedia()).map(i -> new MediaWrapper(i, providerId)).toList(), Pair::create)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SingleObserver<Pair<Paging, List<MediaWrapper>>>() {

        @Override
        public void onSubscribe(final Disposable d) {
            listCall = d;
        }

        @Override
        public void onSuccess(final Pair<Paging, List<MediaWrapper>> value) {
            Paging paging = value.first;
            view.addItems(value.second, !paging.hasNextPage(), paging.getEndCursor());
            items.addAll(value.second);
            showLoaded();
        }

        @Override
        public void onError(final Throwable e) {
            // TODO: 6/24/17 Most of this is not relevant any more
            if (e.getMessage().equals("Canceled")) {
                showLoaded();
            } else if (e.getMessage() != null && e.getMessage().equals(ButterApplication.getAppContext().getString(R.string.movies_error))) {
                view.addItems(null, false, null);
                showLoaded();
            } else {
                Timber.e(e.getMessage());
                view.showErrorMessage(R.string.unknown_error);
                showLoaded();
            }
        }
    });
}
Also used : R(butter.droid.R) Pair(android.util.Pair) Filter(butter.droid.provider.base.filter.Filter) StringRes(android.support.annotation.StringRes) PreferencesHandler(butter.droid.base.content.preferences.PreferencesHandler) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Timber(timber.log.Timber) ArrayList(java.util.ArrayList) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) ButterApplication(butter.droid.base.ButterApplication) SingleObserver(io.reactivex.SingleObserver) ProviderManager(butter.droid.base.manager.internal.provider.ProviderManager) Pager(butter.droid.provider.filter.Pager) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Nullable(android.support.annotation.Nullable) Paging(butter.droid.provider.base.paging.Paging) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Disposable(io.reactivex.disposables.Disposable) Pager(butter.droid.provider.filter.Pager) Paging(butter.droid.provider.base.paging.Paging) ArrayList(java.util.ArrayList) List(java.util.List) Pair(android.util.Pair)

Example 25 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper 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

MediaWrapper (butter.droid.base.providers.media.model.MediaWrapper)26 Bundle (android.os.Bundle)7 Disposable (io.reactivex.disposables.Disposable)6 ProviderManager (butter.droid.base.manager.internal.provider.ProviderManager)4 StreamInfo (butter.droid.base.providers.media.model.StreamInfo)4 Filter (butter.droid.provider.base.filter.Filter)4 Media (butter.droid.provider.base.model.Media)4 Pager (butter.droid.provider.filter.Pager)4 MediaCardItem (butter.droid.tv.presenters.MediaCardPresenter.MediaCardItem)4 Observable (io.reactivex.Observable)4 Single (io.reactivex.Single)4 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)4 Schedulers (io.reactivex.schedulers.Schedulers)4 List (java.util.List)4 Nullable (android.support.annotation.Nullable)3 Pair (android.util.Pair)3 SubtitleWrapper (butter.droid.base.providers.subs.model.SubtitleWrapper)3 Clip (butter.droid.provider.base.model.Clip)3 Paging (butter.droid.provider.base.paging.Paging)3 SingleObserver (io.reactivex.SingleObserver)3