Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SplashViewModel : ViewModel<SplashView>() {
- val percent: ObservableInt = ObservableInt(0);
- override fun init() {
- DbHelper.database.gameDao().count().subscribe { count: Int -> checkGamesCount(count) }
- }
- override fun deinit() {
- }
- private fun checkGamesCount(gamesCount: Int) {
- when {
- gamesCount > 0 -> mvvmView.goToMenu()
- else -> mvvmView.requestExtractGames()
- .observeOn(AndroidSchedulers.mainThread())
- .doOnComplete { mvvmView.goToMenu() }
- .subscribe(percent::set)
- }
- }
- }
Add Comment
Please, Sign In to add comment