viewmodelfactory codelab code example
Example 1: ViewModelFactory code room codelabs\
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(ScoreViewModel::class.java)) {
return ScoreViewModel(finalScore) as T
}
throw IllegalArgumentException("Unknown ViewModel class")
}
Example 2: ViewModelFactory code room codelabs\
class ScoreViewModelFactory(private val finalScore: Int) : ViewModelProvider.Factory {
}