Guest User

Untitled

a guest
May 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. class SplashViewModel : ViewModel<SplashView>() {
  2.  
  3. val percent: ObservableInt = ObservableInt(0);
  4.  
  5. override fun init() {
  6. DbHelper.database.gameDao().count().subscribe { count: Int -> checkGamesCount(count) }
  7. }
  8.  
  9. override fun deinit() {
  10. }
  11.  
  12. private fun checkGamesCount(gamesCount: Int) {
  13. when {
  14. gamesCount > 0 -> mvvmView.goToMenu()
  15. else -> mvvmView.requestExtractGames()
  16. .observeOn(AndroidSchedulers.mainThread())
  17. .doOnComplete { mvvmView.goToMenu() }
  18. .subscribe(percent::set)
  19. }
  20. }
  21. }
Add Comment
Please, Sign In to add comment