Created
November 15, 2019 11:23
-
-
Save 0phelia/da7b0a4752f24dfbb0341f3c2039cfbd 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
class ViewModelFactory(private val mApplication: App, | |
private val irepo: IRepo) : ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
return when (modelClass) { | |
GVM::class.java -> GVM(irepo) as T | |
VVM::class.java -> VVM(mApplication, irepo) as T | |
AVM::class.java -> AVM(irepo) as T | |
else -> throw IllegalArgumentException("Use standard ViewModelProvider to retrieve this ViewModel") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment