Created
August 10, 2019 12:18
-
-
Save photizzo/897d11c0a94b8c0e3e93601fb6066b07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mWeekService.getCachedLessons() // From Cache | |
.doFinally(() -> { | |
mWeekService.getLessons() // From Network | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.map(new Function<WeekResponse, List<WeekModel>>() { | |
@Override | |
public List<WeekModel> apply( | |
@io.reactivex.annotations.NonNull final WeekResponse response) | |
throws Exception { | |
return response.getResult(); | |
} | |
}) | |
.subscribe(new Consumer<List<WeekModel>>() { | |
@Override | |
public void accept( | |
@io.reactivex.annotations.NonNull final List<WeekModel> lessonList) | |
throws Exception { | |
mLessons.addAll(lessonList); | |
mWeekAdapter.set(mDataList); | |
} | |
}) | |
); | |
}) | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.map(new Function<WeekResponse, List<WeekModel>>() { | |
@Override | |
public List<WeekModel> apply( | |
@io.reactivex.annotations.NonNull final WeekResponse response) | |
throws Exception { | |
return response.getResult(); | |
} | |
}) | |
.subscribe(new Consumer<List<WeekModel>>() { | |
@Override | |
public void accept( | |
@io.reactivex.annotations.NonNull final List<WeekModel> lessonList) | |
throws Exception { | |
mLessons.addAll(lessonList); | |
mWeekAdapter.set(mDataList); | |
} | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment