Search in sources :

Example 91 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class PlaylistDetailPresenter method loadPlaylistSongs.

@Override
public void loadPlaylistSongs(long playlistID) {
    mCompositeSubscription.clear();
    Subscription subscription = mUsecase.execute(new GetPlaylistSongs.RequestValues(playlistID)).getSongList().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Song>>() {

        @Override
        public void call(List<Song> songList) {
            mView.showPlaylistSongs(songList);
        }
    });
    mCompositeSubscription.add(subscription);
}
Also used : Song(io.hefuyi.listener.mvp.model.Song) GetPlaylistSongs(io.hefuyi.listener.mvp.usecase.GetPlaylistSongs) List(java.util.List) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Example 92 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class PlaylistDetailFragment method subscribeMetaChangedEvent.

private void subscribeMetaChangedEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(MetaChangedEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).distinctUntilChanged().subscribe(new Action1<MetaChangedEvent>() {

        @Override
        public void call(MetaChangedEvent event) {
            mAdapter.notifyDataSetChanged();
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
        }
    });
    RxBus.getInstance().addSubscription(this, subscription);
}
Also used : MetaChangedEvent(io.hefuyi.listener.event.MetaChangedEvent) Subscription(rx.Subscription)

Example 93 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class PlaylistFragment method subscribePlaylistUpdateEvent.

private void subscribePlaylistUpdateEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(PlaylistUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<PlaylistUpdateEvent>() {

        @Override
        public void call(PlaylistUpdateEvent event) {
            mPresenter.loadPlaylist();
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
        }
    });
    RxBus.getInstance().addSubscription(this, subscription);
}
Also used : PlaylistUpdateEvent(io.hefuyi.listener.event.PlaylistUpdateEvent) Subscription(rx.Subscription)

Example 94 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class QuickControlsFragment method subscribeMetaChangedEvent.

private void subscribeMetaChangedEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(MetaChangedEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<MetaChangedEvent>() {

        @Override
        public void call(MetaChangedEvent event) {
            mPresenter.updateNowPlayingCard();
            mPresenter.loadLyric();
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
        }
    });
    RxBus.getInstance().addSubscription(this, subscription);
}
Also used : MetaChangedEvent(io.hefuyi.listener.event.MetaChangedEvent) Subscription(rx.Subscription)

Example 95 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class FoldersFragment method subscribeMetaChangedEvent.

private void subscribeMetaChangedEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(MetaChangedEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).distinctUntilChanged().subscribe(new Action1<MetaChangedEvent>() {

        @Override
        public void call(MetaChangedEvent event) {
            mAdapter.notifyDataSetChanged();
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
        }
    });
    RxBus.getInstance().addSubscription(this, subscription);
}
Also used : MetaChangedEvent(io.hefuyi.listener.event.MetaChangedEvent) Subscription(rx.Subscription)

Aggregations

Subscription (rx.Subscription)275 Test (org.junit.Test)82 List (java.util.List)66 Action0 (rx.functions.Action0)45 ArrayList (java.util.ArrayList)40 CompositeSubscription (rx.subscriptions.CompositeSubscription)40 CountDownLatch (java.util.concurrent.CountDownLatch)38 Func1 (rx.functions.Func1)24 AtomicReference (java.util.concurrent.atomic.AtomicReference)20 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)19 Observable (rx.Observable)18 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)17 LinkedList (java.util.LinkedList)13 CommandStreamTest (com.netflix.hystrix.metric.CommandStreamTest)11 PlayList (io.github.ryanhoo.music.data.model.PlayList)11 View (android.view.View)10 MetaChangedEvent (io.hefuyi.listener.event.MetaChangedEvent)10 Bundle (android.os.Bundle)9 IOException (java.io.IOException)9 AndroidSchedulers (rx.android.schedulers.AndroidSchedulers)9