Skip to content

Instantly share code, notes, and snippets.

@gfreivasc
Last active April 7, 2019 16:41
Show Gist options
  • Save gfreivasc/a346d4bc411ad2c06cb1906db5cc5510 to your computer and use it in GitHub Desktop.
Save gfreivasc/a346d4bc411ad2c06cb1906db5cc5510 to your computer and use it in GitHub Desktop.
public static ViewModelProvider of(@NonNull FragmentActivity activity,
@Nullable Factory factory) {
Application application = checkApplication(activity);
if (factory == null) {
factory = ViewModelProvider.AndroidViewModelFactory.getInstance(application);
}
return new ViewModelProvider(activity.getViewModelStore(), factory);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment