use of com.simplecity.amp_library.ui.views.QueueView in project Shuttle by timusus.
the class QueuePresenter method removeFromQueue.
public void removeFromQueue(List<Song> songs) {
QueueView queueView = getView();
if (queueView != null) {
queueView.removeFromQueue(songs);
}
MusicUtils.removeFromQueue(songs);
}
use of com.simplecity.amp_library.ui.views.QueueView in project Shuttle by timusus.
the class QueuePresenter method bindView.
@Override
public void bindView(@NonNull QueueView view) {
super.bindView(view);
IntentFilter filter = new IntentFilter();
filter.addAction(MusicService.InternalIntents.META_CHANGED);
addDisposable(RxBroadcast.fromBroadcast(ShuttleApplication.getInstance(), filter).startWith(new Intent(MusicService.InternalIntents.QUEUE_CHANGED)).toFlowable(BackpressureStrategy.LATEST).debounce(150, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(intent -> {
QueueView queueView = getView();
if (queueView != null) {
queueView.updateQueuePosition(MusicUtils.getQueuePosition(), false);
}
}));
filter = new IntentFilter();
filter.addAction(MusicService.InternalIntents.REPEAT_CHANGED);
filter.addAction(MusicService.InternalIntents.SHUFFLE_CHANGED);
filter.addAction(MusicService.InternalIntents.QUEUE_CHANGED);
filter.addAction(MusicService.InternalIntents.SERVICE_CONNECTED);
addDisposable(RxBroadcast.fromBroadcast(ShuttleApplication.getInstance(), filter).startWith(new Intent(MusicService.InternalIntents.QUEUE_CHANGED)).toFlowable(BackpressureStrategy.LATEST).filter(intent -> {
if (MusicService.InternalIntents.QUEUE_CHANGED.equals(intent.getAction()) && intent.getBooleanExtra(MusicService.FROM_USER, false)) {
return false;
}
return true;
}).debounce(150, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(intent -> loadData()));
}
use of com.simplecity.amp_library.ui.views.QueueView in project Shuttle by timusus.
the class QueuePresenter method loadData.
private void loadData() {
QueueView queueView = getView();
if (queueView != null) {
List<ViewModel> data = Stream.of(MusicUtils.getQueue()).map(song -> {
SongView songView = new SongView(song, requestManager) {
@Override
public boolean equals(Object o) {
// are considered to be the same. We lose some RV optimisations here, but at least we don't crash.
return false;
}
};
songView.setClickListener(clickListener);
songView.showAlbumArt(true);
songView.setEditable(true);
return songView;
}).collect(Collectors.toList());
queueView.loadData(data, MusicUtils.getQueuePosition());
}
}
use of com.simplecity.amp_library.ui.views.QueueView in project Shuttle by timusus.
the class QueuePresenter method removeFromQueue.
public void removeFromQueue(int position, Song song) {
QueueView queueView = getView();
if (queueView != null) {
queueView.removeFromQueue(position);
}
MusicUtils.removeFromQueue(position);
}
use of com.simplecity.amp_library.ui.views.QueueView in project Shuttle by timusus.
the class QueuePresenter method playNext.
void playNext(int position) {
int newPosition = MusicUtils.getQueuePosition();
if (MusicUtils.getQueuePosition() < position) {
newPosition += 1;
}
QueueView queueView = getView();
if (queueView != null) {
queueView.moveQueueItem(position, newPosition);
}
MusicUtils.moveQueueItem(position, newPosition);
}
Aggregations