Search in sources :

Example 1 with ProviderWrapper

use of butter.droid.base.manager.internal.provider.model.ProviderWrapper 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;
}
Also used : MediaCardPresenter(butter.droid.tv.presenters.MediaCardPresenter) MediaCardItem(butter.droid.tv.presenters.MediaCardPresenter.MediaCardItem) BehaviorSubject(io.reactivex.subjects.BehaviorSubject) Filter(butter.droid.provider.base.filter.Filter) StringRes(android.support.annotation.StringRes) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Timber(timber.log.Timber) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) ProviderWrapper(butter.droid.base.manager.internal.provider.model.ProviderWrapper) PublishSubject(io.reactivex.subjects.PublishSubject) ProviderManager(butter.droid.base.manager.internal.provider.ProviderManager) Observer(io.reactivex.Observer) R(butter.droid.tv.R) Pager(butter.droid.provider.filter.Pager) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) MediaProvider(butter.droid.provider.MediaProvider) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Single(io.reactivex.Single) MediaProvider(butter.droid.provider.MediaProvider) Filter(butter.droid.provider.base.filter.Filter) Pager(butter.droid.provider.filter.Pager) ArrayList(java.util.ArrayList) ProviderWrapper(butter.droid.base.manager.internal.provider.model.ProviderWrapper)

Example 2 with ProviderWrapper

use of butter.droid.base.manager.internal.provider.model.ProviderWrapper in project butter-android by butterproject.

the class MainPresenterImpl method displayProviderData.

private void displayProviderData(final int providerId) {
    this.selectedProviderId = providerId;
    final ProviderWrapper provider = providerManager.getProvider(providerId);
    final MediaProvider mediaProvider = provider.getMediaProvider();
    unsubscribeProviderId(providerId);
    Observable.concat(mediaProvider.genres().filter(genres -> genres != null && genres.size() > 0).map(g -> new NavInfo(R.id.nav_item_genre, 0, R.string.genres, providerId)).toObservable(), mediaProvider.navigation().flatMapObservable(Observable::fromIterable).map(item -> new NavInfo(item, providerId))).toList().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SingleObserver<List<NavInfo>>() {

        @Override
        public void onSubscribe(final Disposable d) {
            providerDataDisposable.add(providerId, d);
        }

        @Override
        public void onSuccess(final List<NavInfo> value) {
            // TODO: 8/5/17 Do we need this
            // boolean hasGenres = value.first != null && value.first.size() > 0;
            view.displayProvider(provider.getDisplayName(), value);
        }

        @Override
        public void onError(final Throwable e) {
        // TODO: 8/5/17 Display error
        }
    });
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) NonNull(android.support.annotation.NonNull) UiGenre(butter.droid.ui.main.genre.list.model.UiGenre) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) ArrayList(java.util.ArrayList) Manifest(android.Manifest) PrefManager(butter.droid.base.manager.prefs.PrefManager) NavInfo(butter.droid.ui.main.pager.NavInfo) ProviderManager(butter.droid.base.manager.internal.provider.ProviderManager) KeyDisposable(butter.droid.base.utils.rx.KeyDisposable) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) R(butter.droid.R) ContextCompat(android.support.v4.content.ContextCompat) PreferencesHandler(butter.droid.base.content.preferences.PreferencesHandler) PreferencesActivity(butter.droid.ui.preferences.PreferencesActivity) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) ProviderWrapper(butter.droid.base.manager.internal.provider.model.ProviderWrapper) SingleObserver(io.reactivex.SingleObserver) TermsPresenterImpl(butter.droid.ui.terms.TermsPresenterImpl) MediaProvider(butter.droid.provider.MediaProvider) Activity(android.app.Activity) KeyDisposable(butter.droid.base.utils.rx.KeyDisposable) Disposable(io.reactivex.disposables.Disposable) MediaProvider(butter.droid.provider.MediaProvider) ArrayList(java.util.ArrayList) List(java.util.List) NavInfo(butter.droid.ui.main.pager.NavInfo) ProviderWrapper(butter.droid.base.manager.internal.provider.model.ProviderWrapper) Observable(io.reactivex.Observable)

Example 3 with ProviderWrapper

use of butter.droid.base.manager.internal.provider.model.ProviderWrapper in project butter-android by butterproject.

the class NavigationDrawerPresenterImpl method getNavigationItems.

private List<NavigationDrawerFragment.AbsNavDrawerItem> getNavigationItems() {
    List<AbsNavDrawerItem> navItems = new ArrayList<>();
    navItems.add(new HeaderNavDrawerItem());
    ProviderWrapper[] providers = providerManager.getProviders();
    for (int i = 0; i < providers.length; i++) {
        final ProviderWrapper provider = providers[i];
        navItems.add(new ProviderNavDrawerItem(provider.getDisplayName(), provider.getIcon(), i));
    }
    navItems.add(new ScreenNavDrawerItem(R.string.preferences, R.drawable.ic_nav_settings, PreferencesActivity.class));
    navItems.get(selectedPosition).setSelected(true);
    return navItems;
}
Also used : AbsNavDrawerItem(butter.droid.ui.main.navigation.NavigationDrawerFragment.AbsNavDrawerItem) ProviderNavDrawerItem(butter.droid.ui.main.navigation.NavigationDrawerFragment.ProviderNavDrawerItem) PreferencesActivity(butter.droid.ui.preferences.PreferencesActivity) ArrayList(java.util.ArrayList) HeaderNavDrawerItem(butter.droid.ui.main.navigation.NavigationDrawerFragment.HeaderNavDrawerItem) ScreenNavDrawerItem(butter.droid.ui.main.navigation.NavigationDrawerFragment.ScreenNavDrawerItem) ProviderWrapper(butter.droid.base.manager.internal.provider.model.ProviderWrapper)

Example 4 with ProviderWrapper

use of butter.droid.base.manager.internal.provider.model.ProviderWrapper in project butter-android by butterproject.

the class ProviderModule method provideVodoWrapper.

@Provides
@ProviderScope
@ElementsIntoSet
Set<ProviderWrapper> provideVodoWrapper(final VodoProvider vodoProvider, final OpenSubsProvider openSubsProvider, final MockMediaProvider mockProvider, final MockSubsProvider mockSubsProvider) {
    Set<ProviderWrapper> set = new TreeSet<>((o1, o2) -> o2.getPosition() - o1.getPosition());
    set.add(new ProviderWrapper(vodoProvider, openSubsProvider, R.string.vodo_label, R.drawable.ic_nav_movies, 0));
    set.add(new ProviderWrapper(mockProvider, mockSubsProvider, butter.droid.provider.mock.R.string.title_movies, butter.droid.provider.mock.R.drawable.ic_nav_movies, 1));
    return set;
}
Also used : TreeSet(java.util.TreeSet) ProviderWrapper(butter.droid.base.manager.internal.provider.model.ProviderWrapper) ProviderScope(butter.droid.provider.base.ProviderScope) ElementsIntoSet(dagger.multibindings.ElementsIntoSet) Provides(dagger.Provides)

Aggregations

ProviderWrapper (butter.droid.base.manager.internal.provider.model.ProviderWrapper)4 ArrayList (java.util.ArrayList)3 ProviderManager (butter.droid.base.manager.internal.provider.ProviderManager)2 MediaProvider (butter.droid.provider.MediaProvider)2 PreferencesActivity (butter.droid.ui.preferences.PreferencesActivity)2 Observable (io.reactivex.Observable)2 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)2 Disposable (io.reactivex.disposables.Disposable)2 Schedulers (io.reactivex.schedulers.Schedulers)2 List (java.util.List)2 Manifest (android.Manifest)1 Activity (android.app.Activity)1 Context (android.content.Context)1 PackageManager (android.content.pm.PackageManager)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 StringRes (android.support.annotation.StringRes)1 ContextCompat (android.support.v4.content.ContextCompat)1 R (butter.droid.R)1 PreferencesHandler (butter.droid.base.content.preferences.PreferencesHandler)1