mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-23 00:40:58 +01:00
android: Convert PlatformGamesPresenter to Kotlin
This commit is contained in:
parent
0b2350ad5b
commit
fcce7b898f
2 changed files with 30 additions and 42 deletions
|
@ -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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue