From fcce7b898f5f8b9821157097ac38612bd60d0792 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sat, 11 Mar 2023 00:35:01 -0500 Subject: [PATCH] android: Convert PlatformGamesPresenter to Kotlin --- .../ui/platform/PlatformGamesPresenter.java | 42 ------------------- .../ui/platform/PlatformGamesPresenter.kt | 30 +++++++++++++ 2 files changed, 30 insertions(+), 42 deletions(-) delete mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.java create mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.kt diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.java deleted file mode 100644 index effd4a7d1..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.yuzu.yuzu_emu.ui.platform; - - -import org.yuzu.yuzu_emu.YuzuApplication; -import org.yuzu.yuzu_emu.model.GameDatabase; -import org.yuzu.yuzu_emu.utils.Log; - -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; - -public final class PlatformGamesPresenter { - private final PlatformGamesView mView; - - public PlatformGamesPresenter(PlatformGamesView view) { - mView = view; - } - - public void onCreateView() { - loadGames(); - } - - public void refresh() { - Log.debug("[PlatformGamesPresenter] : Refreshing..."); - loadGames(); - } - - private void loadGames() { - Log.debug("[PlatformGamesPresenter] : Loading games..."); - - GameDatabase databaseHelper = YuzuApplication.databaseHelper; - - databaseHelper.getGames() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(games -> - { - Log.debug("[PlatformGamesPresenter] : Load finished, swapping cursor..."); - - mView.showGames(games); - }); - } -} diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.kt new file mode 100644 index 000000000..f888d579f --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/platform/PlatformGamesPresenter.kt @@ -0,0 +1,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!!) + } + } +}