Search in sources :

Example 96 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class PlayRankingFragment 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 97 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class SearchFragment method subscribeMediaUpdateEvent.

private void subscribeMediaUpdateEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {

        @Override
        public void call(MediaUpdateEvent event) {
            mPresenter.search(queryString);
        }
    }, new Action1<Throwable>() {

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

Example 98 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class SongsFragment method subscribeRecentlyPlayEvent.

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

        @Override
        public void call(RecentlyPlayEvent event) {
            mPresenter.loadSongs(action);
        }
    }, new Action1<Throwable>() {

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

Example 99 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class SongsFragment method subscribeFavourateSongEvent.

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

        @Override
        public void call(FavourateSongEvent event) {
            mPresenter.loadSongs(action);
        }
    }, new Action1<Throwable>() {

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

Example 100 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class SongsFragment method subscribeMediaUpdateEvent.

private void subscribeMediaUpdateEvent() {
    Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {

        @Override
        public void call(MediaUpdateEvent event) {
            mPresenter.loadSongs(action);
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
        }
    });
    RxBus.getInstance().addSubscription(this, subscription);
}
Also used : MediaUpdateEvent(io.hefuyi.listener.event.MediaUpdateEvent) 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