Skip to content

Instantly share code, notes, and snippets.

@user-mw
Created December 7, 2019 14:10
Show Gist options
  • Save user-mw/eb98c17f7819876121c6c6da3a017ec9 to your computer and use it in GitHub Desktop.
Save user-mw/eb98c17f7819876121c6c6da3a017ec9 to your computer and use it in GitHub Desktop.
FragmentActivity getViewModelStore()
public ViewModelStore getViewModelStore() {
// Code
if (mViewModelStore == null) {
NonConfigurationInstances nc =
(NonConfigurationInstances) getLastNonConfigurationInstance();
if (nc != null) {
mViewModelStore = nc.viewModelStore;
}
if (mViewModelStore == null) {
mViewModelStore = new ViewModelStore();
}
}
return mViewModelStore;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment