Skip to content

Instantly share code, notes, and snippets.

@joseprl89
Created May 25, 2018 17:59
Show Gist options
  • Save joseprl89/be0dbdf512603b61f49c1c6f34b13c2a to your computer and use it in GitHub Desktop.
Save joseprl89/be0dbdf512603b61f49c1c6f34b13c2a to your computer and use it in GitHub Desktop.
public static ViewModelStore of(@NonNull Fragment fragment) {
if (fragment instanceof ViewModelStoreOwner) {
return ((ViewModelStoreOwner) fragment).getViewModelStore();
}
return holderFragmentFor(fragment).getViewModelStore();
}
...
public static HolderFragment holderFragmentFor(Fragment fragment) {
return sHolderFragmentManager.holderFragmentFor(fragment);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment