Created
September 3, 2022 01:30
-
-
Save fayaz07/c9b5f73509354e012bb7a2db62a54f50 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 MViewModelFactory(private val todoDao: TodoDao) : ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
return when(modelClass) { | |
MainViewModel::class.java -> { | |
MainViewModel(todoDao) as T | |
} | |
CreateViewModel::class.java -> { | |
CreateViewModel(todoDao) as T | |
} | |
else -> { | |
throw IllegalStateException() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment