Last active
March 31, 2019 13:50
-
-
Save CostaFot/884922961ee612025a6e510ded142c01 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Copy pasta how to ViewModelFactory | |
* Google says you cannot pass stuff in the ViewModel constructor like normal | |
* Just do this I guess, who am I to judge | |
*/ | |
class NowPlayingMoviesViewModelFactory( | |
private val placeholderApi: MovieApi, | |
private val apiKey: String, | |
private val scheduler: Scheduler | |
) : ViewModelProvider.Factory { | |
override fun <T : ViewModel?> create(modelClass: Class<T>): T { | |
@Suppress("UNCHECKED_CAST") | |
return NowPlayingMoviesViewModel( | |
placeholderApi, | |
apiKey, | |
scheduler | |
) as T | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment