Last active
April 9, 2018 04:37
-
-
Save vincent-paing/f478d249e49f0292697f0a6969d159fe 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
val viewModel = viewModelProviders.of(this, newsListingViewModel).get(NewsListingViewModel::class.java) |
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
class NewsListingViewModel constructor( | |
val getNews: GetNews | |
) : BaseViewModel() { | |
//Implementations | |
} |
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
class NewsListingViewModelFactory @Inject constructor( | |
private val getNews: GetNews | |
) : ViewModelProvider.Factory { | |
override fun <T : ViewModel?> create(modelClass: Class<T>): T { | |
if (modelClass.isAssignableFrom(NewsListingViewModel::class.java)) { | |
return NewsListingViewModel(getNews) as T | |
} | |
throw IllegalArgumentException("Unknown ViewModel class") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment