summaryrefslogtreecommitdiffstats
path: root/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.kt
blob: f888d579f7030e2bc641a562f65eb88dacdb77f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.yuzu.yuzu_emu.ui.platform

import android.database.Cursor
import org.yuzu.yuzu_emu.YuzuApplication
import org.yuzu.yuzu_emu.utils.Log
import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers

class PlatformGamesPresenter(private val view: PlatformGamesView) {
    fun onCreateView() {
        loadGames()
    }

    fun refresh() {
        Log.debug("[PlatformGamesPresenter] : Refreshing...")
        loadGames()
    }

    private fun loadGames() {
        Log.debug("[PlatformGamesPresenter] : Loading games...")
        val databaseHelper = YuzuApplication.databaseHelper
        databaseHelper!!.games
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe { games: Cursor? ->
                Log.debug("[PlatformGamesPresenter] : Load finished, swapping cursor...")
                view.showGames(games!!)
            }
    }
}