use of com.simplecityapps.recycler_adapter.model.ViewModel 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;
}
}
}));
}
Aggregations