Search in sources :

Example 1 with NavInfo

use of butter.droid.ui.main.pager.NavInfo 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)

Aggregations

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 ContextCompat (android.support.v4.content.ContextCompat)1 R (butter.droid.R)1 PreferencesHandler (butter.droid.base.content.preferences.PreferencesHandler)1 ProviderManager (butter.droid.base.manager.internal.provider.ProviderManager)1 ProviderWrapper (butter.droid.base.manager.internal.provider.model.ProviderWrapper)1 PrefManager (butter.droid.base.manager.prefs.PrefManager)1 KeyDisposable (butter.droid.base.utils.rx.KeyDisposable)1 MediaProvider (butter.droid.provider.MediaProvider)1 UiGenre (butter.droid.ui.main.genre.list.model.UiGenre)1 NavInfo (butter.droid.ui.main.pager.NavInfo)1 PreferencesActivity (butter.droid.ui.preferences.PreferencesActivity)1 TermsPresenterImpl (butter.droid.ui.terms.TermsPresenterImpl)1 Observable (io.reactivex.Observable)1 SingleObserver (io.reactivex.SingleObserver)1