Last active
January 30, 2018 14:24
-
-
Save HIFILEO/3929471d9e06074069721b406627c0fc to your computer and use it in GitHub Desktop.
This file contains 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
//Save | |
@Override | |
public void onSaveInstanceState(Bundle outState) { | |
super.onSaveInstanceState(outState); | |
outState.putParcelable(LAST_UIMODEL, latestUiModel); | |
} | |
//Init ViewModel with saved state | |
public void init(@Nullable UiModel restoredUiModel) { | |
if (initialUiModel == null) { | |
if (restoredUiModel == null) { | |
initialUiModel = UiModel.initState(); | |
startEventsObservable = Observable.just(new ScrollEvent(initialUiModel.getPageNumber() + 1)); | |
} else { | |
//restore required | |
initialUiModel = UiModel.restoreState(restoredUiModel.getPageNumber(), new ArrayList<>(), null); | |
startEventsObservable = Observable.just(new RestoreEvent(initialUiModel.getPageNumber())); | |
} | |
bind(); | |
} | |
} | |
/*Scan in Main Pipe*/ | |
.scan(initialUiModel, (uiModel, result) -> { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment