Search in sources :

Example 1 with QueueView

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);
}
Also used : QueueView(com.simplecity.amp_library.ui.views.QueueView)

Example 2 with QueueView

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()));
}
Also used : Context(android.content.Context) Stream(com.annimon.stream.Stream) SongView(com.simplecity.amp_library.ui.modelviews.SongView) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) Intent(android.content.Intent) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) NonNull(android.support.annotation.NonNull) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) MenuItem(android.view.MenuItem) Song(com.simplecity.amp_library.model.Song) RequestManager(com.bumptech.glide.RequestManager) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) BackpressureStrategy(io.reactivex.BackpressureStrategy) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) Collectors(com.annimon.stream.Collectors) QueueView(com.simplecity.amp_library.ui.views.QueueView) Playlist(com.simplecity.amp_library.model.Playlist) IntentFilter(android.content.IntentFilter) PopupMenu(android.support.v7.widget.PopupMenu) RxBroadcast(com.cantrowitz.rxbroadcast.RxBroadcast) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) TimeUnit(java.util.concurrent.TimeUnit) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) List(java.util.List) MusicService(com.simplecity.amp_library.playback.MusicService) IntentFilter(android.content.IntentFilter) QueueView(com.simplecity.amp_library.ui.views.QueueView) Intent(android.content.Intent)

Example 3 with QueueView

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());
    }
}
Also used : Context(android.content.Context) Stream(com.annimon.stream.Stream) SongView(com.simplecity.amp_library.ui.modelviews.SongView) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) Intent(android.content.Intent) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) NonNull(android.support.annotation.NonNull) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) MenuItem(android.view.MenuItem) Song(com.simplecity.amp_library.model.Song) RequestManager(com.bumptech.glide.RequestManager) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) BackpressureStrategy(io.reactivex.BackpressureStrategy) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) Collectors(com.annimon.stream.Collectors) QueueView(com.simplecity.amp_library.ui.views.QueueView) Playlist(com.simplecity.amp_library.model.Playlist) IntentFilter(android.content.IntentFilter) PopupMenu(android.support.v7.widget.PopupMenu) RxBroadcast(com.cantrowitz.rxbroadcast.RxBroadcast) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) TimeUnit(java.util.concurrent.TimeUnit) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) List(java.util.List) MusicService(com.simplecity.amp_library.playback.MusicService) QueueView(com.simplecity.amp_library.ui.views.QueueView) SongView(com.simplecity.amp_library.ui.modelviews.SongView) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel)

Example 4 with QueueView

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);
}
Also used : QueueView(com.simplecity.amp_library.ui.views.QueueView)

Example 5 with QueueView

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);
}
Also used : QueueView(com.simplecity.amp_library.ui.views.QueueView)

Aggregations

QueueView (com.simplecity.amp_library.ui.views.QueueView)5 Context (android.content.Context)2 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2 NonNull (android.support.annotation.NonNull)2 PopupMenu (android.support.v7.widget.PopupMenu)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2 Collectors (com.annimon.stream.Collectors)2 Stream (com.annimon.stream.Stream)2 RequestManager (com.bumptech.glide.RequestManager)2 RxBroadcast (com.cantrowitz.rxbroadcast.RxBroadcast)2 ShuttleApplication (com.simplecity.amp_library.ShuttleApplication)2 Playlist (com.simplecity.amp_library.model.Playlist)2 Song (com.simplecity.amp_library.model.Song)2 MusicService (com.simplecity.amp_library.playback.MusicService)2 SongView (com.simplecity.amp_library.ui.modelviews.SongView)2 ContextualToolbarHelper (com.simplecity.amp_library.utils.ContextualToolbarHelper)2 MenuUtils (com.simplecity.amp_library.utils.MenuUtils)2 MusicUtils (com.simplecity.amp_library.utils.MusicUtils)2