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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations