Search in sources :

Example 1 with NYTimesStory

use of io.realm.examples.newsreader.model.entity.NYTimesStory 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

NYTimesStory (io.realm.examples.newsreader.model.entity.NYTimesStory)1 Subscription (rx.Subscription)1 CompositeSubscription (rx.subscriptions.CompositeSubscription)1