Search in sources :

Example 1 with FavoriteChangeEvent

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

the class MusicPlayerPresenter method setSongAsFavorite.

@Override
public void setSongAsFavorite(Song song, boolean favorite) {
    Subscription subscription = mRepository.setSongAsFavorite(song, favorite).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<Song>() {

        @Override
        public void onCompleted() {
        // Empty
        }

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

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

Aggregations

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