summaryrefslogtreecommitdiffstats
path: root/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.kt
blob: 0b9da5f579623c91468fd6ce04b6b070c1ec9450 (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
31
32
33
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

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!!)
            }
    }
}