Created
October 2, 2017 09:41
-
-
Save kakai248/f3aa28187affd8b7f941cfafe26a445f to your computer and use it in GitHub Desktop.
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 class ViewModelInjectionFactory<VM extends ViewModel> implements ViewModelProvider.Factory { | |
private Lazy<VM> viewModel; | |
@Inject | |
public ViewModelInjectionFactory(Lazy<VM> viewModel) { | |
this.viewModel = viewModel; | |
} | |
@Override | |
@SuppressWarnings("unchecked cast") | |
public <T extends ViewModel> T create(Class<T> modelClass) { | |
return (T) viewModel.get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment