Search in sources :

Example 1 with PlayListUpdatedEvent

use of io.github.ryanhoo.music.event.PlayListUpdatedEvent in project StylishMusicPlayer by ryanhoo.

the class PlayListDetailsPresenter method delete.

@Override
public void delete(final Song song, PlayList playList) {
    playList.removeSong(song);
    Subscription subscription = mRepository.update(playList).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<PlayList>() {

        @Override
        public void onStart() {
            mView.showLoading();
        }

        @Override
        public void onCompleted() {
            mView.hideLoading();
        }

        @Override
        public void onError(Throwable e) {
            mView.hideLoading();
            mView.handleError(e);
        }

        @Override
        public void onNext(PlayList playList) {
            mView.onSongDeleted(song);
            RxBus.getInstance().post(new PlayListUpdatedEvent(playList));
        }
    });
    mSubscriptions.add(subscription);
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList) PlayListUpdatedEvent(io.github.ryanhoo.music.event.PlayListUpdatedEvent) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Example 2 with PlayListUpdatedEvent

use of io.github.ryanhoo.music.event.PlayListUpdatedEvent in project StylishMusicPlayer by ryanhoo.

the class FolderPresenter method addFolderToPlayList.

@Override
public void addFolderToPlayList(final Folder folder, PlayList playList) {
    if (folder.getSongs().isEmpty())
        return;
    if (playList.isFavorite()) {
        for (Song song : folder.getSongs()) {
            song.setFavorite(true);
        }
    }
    playList.addSong(folder.getSongs(), 0);
    Subscription subscription = mRepository.update(playList).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<PlayList>() {

        @Override
        public void onStart() {
            mView.showLoading();
        }

        @Override
        public void onCompleted() {
            mView.hideLoading();
        }

        @Override
        public void onError(Throwable e) {
            mView.hideLoading();
            mView.handleError(e);
        }

        @Override
        public void onNext(PlayList playList) {
            RxBus.getInstance().post(new PlayListUpdatedEvent(playList));
        }
    });
    mSubscriptions.add(subscription);
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList) PlayListUpdatedEvent(io.github.ryanhoo.music.event.PlayListUpdatedEvent) Song(io.github.ryanhoo.music.data.model.Song) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Example 3 with PlayListUpdatedEvent

use of io.github.ryanhoo.music.event.PlayListUpdatedEvent in project StylishMusicPlayer by ryanhoo.

the class PlayListDetailsPresenter method addSongToPlayList.

@Override
public void addSongToPlayList(Song song, PlayList playList) {
    if (playList.isFavorite()) {
        song.setFavorite(true);
    }
    playList.addSong(song, 0);
    Subscription subscription = mRepository.update(playList).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<PlayList>() {

        @Override
        public void onStart() {
            mView.showLoading();
        }

        @Override
        public void onCompleted() {
            mView.hideLoading();
        }

        @Override
        public void onError(Throwable e) {
            mView.hideLoading();
            mView.handleError(e);
        }

        @Override
        public void onNext(PlayList playList) {
            RxBus.getInstance().post(new PlayListUpdatedEvent(playList));
        }
    });
    mSubscriptions.add(subscription);
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList) PlayListUpdatedEvent(io.github.ryanhoo.music.event.PlayListUpdatedEvent) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Aggregations

PlayList (io.github.ryanhoo.music.data.model.PlayList)3 PlayListUpdatedEvent (io.github.ryanhoo.music.event.PlayListUpdatedEvent)3 Subscription (rx.Subscription)3 CompositeSubscription (rx.subscriptions.CompositeSubscription)3 Song (io.github.ryanhoo.music.data.model.Song)1