Search in sources :

Example 31 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 32 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)

Example 33 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class SongsFragment 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 34 with Subscription

use of rx.Subscription in project ListenerMusicPlayer by hefuyicoder.

the class FolderSongsFragment 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 35 with Subscription

use of rx.Subscription in project realm-java by realm.

the class DetailsPresenter method onResume.

@Override
public void onResume() {
    // Show story details
    Subscription detailsSubscription = model.getStory(storyId).subscribe(new Action1<NYTimesStory>() {

        @Override
        public void call(NYTimesStory story) {
            view.hideLoader();
            view.showStory(story);
            view.setRead(story.isRead());
        }
    });
    // Mark story as read if screen is visible for 2 seconds
    Subscription timerSubscription = Observable.timer(2, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Long>() {

        @Override
        public void call(Long aLong) {
            model.markAsRead(storyId, true);
        }
    });
    subscriptions = new CompositeSubscription(detailsSubscription, timerSubscription);
}
Also used : NYTimesStory(io.realm.examples.newsreader.model.entity.NYTimesStory) CompositeSubscription(rx.subscriptions.CompositeSubscription) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Aggregations

Subscription (rx.Subscription)302 Test (org.junit.Test)82 List (java.util.List)75 CompositeSubscription (rx.subscriptions.CompositeSubscription)55 Action0 (rx.functions.Action0)45 ArrayList (java.util.ArrayList)41 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 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)17 Observable (rx.Observable)17 LinkedList (java.util.LinkedList)13 CommandStreamTest (com.netflix.hystrix.metric.CommandStreamTest)11 PlayList (io.github.ryanhoo.music.data.model.PlayList)11 MetaChangedEvent (io.hefuyi.listener.event.MetaChangedEvent)10 View (android.view.View)9 IOException (java.io.IOException)9 AndroidSchedulers (rx.android.schedulers.AndroidSchedulers)8 Intent (android.content.Intent)7