use of butter.droid.provider.base.filter.Filter in project butter-android by butterproject.
the class TVMediaGridPresenterImpl method loadItems.
private void loadItems(@Nullable String endCursor) {
cancelCurrentCall();
providerManager.getMediaProvider(providerId).items(filter, new Pager(endCursor)).flatMap(i -> Single.zip(Single.just(i).map(ItemsWrapper::getMedia).flatMapObservable(Observable::fromIterable).map(media -> new MediaWrapper(media, providerId)).map(MediaCardItem::new).toList(), Single.just(i).map(ItemsWrapper::getPaging), Pair::create)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SingleObserver<Pair<List<MediaCardItem>, Paging>>() {
@Override
public void onSubscribe(final Disposable d) {
currentCall = d;
}
@Override
public void onSuccess(final Pair<List<MediaCardItem>, Paging> value) {
view.appendItems(value.first, !value.second.hasNextPage(), value.second.getEndCursor());
}
@Override
public void onError(final Throwable e) {
view.displayError("Error getting show list");
}
});
}
use of butter.droid.provider.base.filter.Filter in project butter-android by butterproject.
the class BaseMediaListFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Bundle arguments = getArguments();
int providerId = arguments.getInt(EXTRA_PROVIDER);
Filter filter = arguments.getParcelable(EXTRA_FILTER);
presenter.onActivityCreated(providerId, filter);
}
use of butter.droid.provider.base.filter.Filter 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();
}
}
});
}
Aggregations