use of butter.droid.provider.base.filter.Filter in project butter-android by butterproject.
the class TVMediaGridActivity method onCreate.
@SuppressLint("MissingSuperCall")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState, R.layout.activity_movie_media_grid);
Bundle extras = getIntent().getExtras();
final Filter filter = extras.getParcelable(EXTRA_FILTER);
@StringRes int title = extras.getInt(EXTRA_TITLE);
final int providerId = extras.getInt(EXTRA_PROVIDER);
// add media fragment
getSupportFragmentManager().beginTransaction().replace(R.id.fragment, TVMediaGridFragment.newInstance(providerId, title, filter)).commit();
}
use of butter.droid.provider.base.filter.Filter in project butter-android by butterproject.
the class TVMediaGridFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
backgroundUpdater.initialise(getActivity(), R.color.black);
setupUi();
Bundle args = getArguments();
int providerId = args.getInt(ARG_PROVIDER);
Filter filter = args.getParcelable(ARG_FILTER);
presenter.onCreate(providerId, filter);
}
use of butter.droid.provider.base.filter.Filter in project butter-android by butterproject.
the class TVOverviewPresenterImpl method loadProviderMedia.
private void loadProviderMedia(final int providerId) {
cancelMovieCall(providerId);
final butter.droid.provider.MediaProvider provider = providerManager.getMediaProvider(providerId);
provider.getDefaultSorter().flatMap(sorter -> {
Filter f;
if (sorter.isPresent()) {
f = new Filter(null, sorter.get());
} else {
f = new Filter(null, null);
}
return provider.items(f, new Pager(null));
}).flatMap(w -> Single.zip(Single.just(w.getPaging()), Observable.fromIterable(w.getMedia()).map(m -> new MediaWrapper(m, providerId)).toList(), Pair::create)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SingleObserver<Pair<Paging, List<MediaWrapper>>>() {
@Override
public void onSubscribe(final Disposable d) {
listRequests.add(providerId, d);
}
@Override
public void onSuccess(final Pair<Paging, List<MediaWrapper>> items) {
List<MediaWrapper> mediaItems = items.second;
List<MediaCardItem> cardItems = convertMediaToOverview(mediaItems);
view.displayProviderData(providerId, cardItems);
if (selectedRow == 0) {
view.updateBackgroundImage(mediaItems.get(0).getMedia().getBackdrop());
}
}
@Override
public void onError(final Throwable e) {
view.showErrorMessage(R.string.movies_error);
}
});
}
use of butter.droid.provider.base.filter.Filter in project butter-android by butterproject.
the class TVSearchPresenterImpl method getProviderRequests.
private List<Single<SearchResult>> getProviderRequests(String query) {
List<Single<SearchResult>> requests = new ArrayList<>();
ProviderWrapper[] providers = providerManager.getProviders();
for (int i = 0; i < providers.length; i++) {
MediaProvider provider = providers[i].getMediaProvider();
final int providerId = i;
// TODO: 6/17/17 Define title of search row
requests.add(provider.items(new Filter(null, null, query), new Pager(null)).flatMapObservable(w -> Observable.fromIterable(w.getMedia())).map(m -> new MediaWrapper(m, providerId)).toList().map(l -> new SearchResult(R.string.movie_results, l)));
}
return requests;
}
use of butter.droid.provider.base.filter.Filter in project butter-android by butterproject.
the class MediaListPresenterImpl method onGenreChanged.
@Override
public void onGenreChanged(UiGenre genre) {
Genre g = genre.getGenre();
if (filter.getGenre() == null || !filter.getGenre().equals(g)) {
filter = new Filter(g, filter.getSorter(), filter.getQuery());
items.clear();
view.refreshAdapter();
}
}
Aggregations