Search in sources :

Example 41 with RequestManager

use of com.bumptech.glide.RequestManager in project Shuttle by timusus.

the class QueuePagerPresenter method bindView.

@Override
public void bindView(@NonNull QueuePagerView view) {
    super.bindView(view);
    IntentFilter filter = new IntentFilter();
    filter.addAction(InternalIntents.META_CHANGED);
    filter.addAction(InternalIntents.REPEAT_CHANGED);
    filter.addAction(InternalIntents.SHUFFLE_CHANGED);
    filter.addAction(InternalIntents.QUEUE_CHANGED);
    filter.addAction(InternalIntents.SERVICE_CONNECTED);
    addDisposable(RxBroadcast.fromBroadcast(application, filter).startWith(new Intent(InternalIntents.QUEUE_CHANGED)).toFlowable(BackpressureStrategy.LATEST).observeOn(AndroidSchedulers.mainThread()).subscribe(intent -> {
        final String action = intent.getAction();
        QueuePagerView queuePagerView = getView();
        if (queuePagerView == null) {
            return;
        }
        if (action != null) {
            switch(action) {
                case InternalIntents.META_CHANGED:
                    queuePagerView.updateQueuePosition(mediaManager.getQueuePosition());
                    break;
                case InternalIntents.REPEAT_CHANGED:
                case InternalIntents.SHUFFLE_CHANGED:
                case InternalIntents.QUEUE_CHANGED:
                case InternalIntents.SERVICE_CONNECTED:
                    List<ViewModel> items = Stream.of(mediaManager.getQueue()).map(queueItem -> new QueuePagerItemView(queueItem.getSong(), requestManager, settingsManager)).collect(Collectors.toList());
                    queuePagerView.loadData(items, mediaManager.getQueuePosition());
                    break;
            }
        }
    }));
}
Also used : QueuePagerItemView(com.simplecity.amp_library.ui.modelviews.QueuePagerItemView) BackpressureStrategy(io.reactivex.BackpressureStrategy) Collectors(com.annimon.stream.Collectors) Stream(com.annimon.stream.Stream) MediaManager(com.simplecity.amp_library.playback.MediaManager) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) NonNull(android.support.annotation.NonNull) RxBroadcast(com.cantrowitz.rxbroadcast.RxBroadcast) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) SettingsManager(com.simplecity.amp_library.utils.SettingsManager) Inject(javax.inject.Inject) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) List(java.util.List) InternalIntents(com.simplecity.amp_library.playback.constants.InternalIntents) RequestManager(com.bumptech.glide.RequestManager) Presenter(com.simplecity.amp_library.ui.common.Presenter) IntentFilter(android.content.IntentFilter) QueuePagerItemView(com.simplecity.amp_library.ui.modelviews.QueuePagerItemView) Intent(android.content.Intent) List(java.util.List)

Aggregations

RequestManager (com.bumptech.glide.RequestManager)41 Context (android.content.Context)15 View (android.view.View)15 Bundle (android.os.Bundle)14 Glide (com.bumptech.glide.Glide)14 Test (org.junit.Test)14 Stream (com.annimon.stream.Stream)13 MusicUtils (com.simplecity.amp_library.utils.MusicUtils)13 List (java.util.List)13 PopupMenu (android.support.v7.widget.PopupMenu)11 MenuItem (android.view.MenuItem)11 Toast (android.widget.Toast)11 R (com.simplecity.amp_library.R)11 MenuUtils (com.simplecity.amp_library.utils.MenuUtils)11 Intent (android.content.Intent)10 LayoutInflater (android.view.LayoutInflater)10 ViewGroup (android.view.ViewGroup)10 Song (com.simplecity.amp_library.model.Song)10 ViewModel (com.simplecityapps.recycler_adapter.model.ViewModel)10 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)10