Created
May 16, 2018 03:10
-
-
Save Morgazmo/dd98bb83c8844c45977c5211bbc27ea6 to your computer and use it in GitHub Desktop.
Method
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
public static MyViewModel obtainViewModel(FragmentActivity activity) { | |
Log.d(TAG, "obtainViewModel"); | |
// Use a Factory to inject dependencies into the ViewModel | |
ViewModelFactory factory = ViewModelFactory.getInstance(activity.getApplication()); | |
return ViewModelProviders.of(activity, factory).get(MyViewModel.class); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment