Skip to content

Instantly share code, notes, and snippets.

@Pluu
Created March 16, 2020 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pluu/7b7a7c38064bba967754e5fe4334ba5d to your computer and use it in GitHub Desktop.
Save Pluu/7b7a7c38064bba967754e5fe4334ba5d to your computer and use it in GitHub Desktop.
public final class SavedStateHandle {
static SavedStateHandle createHandle(@Nullable Bundle restoredState,
@Nullable Bundle defaultState) {
...
Map<String, Object> state = new HashMap<>();
if (defaultState != null) {
for (String key : defaultState.keySet()) {
state.put(key, defaultState.get(key));
}
}
...
ArrayList keys = restoredState.getParcelableArrayList(KEYS);
ArrayList values = restoredState.getParcelableArrayList(VALUES);
...
for (int i = 0; i < keys.size(); i++) {
state.put((String) keys.get(i), values.get(i));
}
return new SavedStateHandle(state);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment