|
@@ -1,81 +0,0 @@
|
|
|
-package org.yuzu.yuzu_emu.ui.main;
|
|
|
|
|
-
|
|
|
|
|
-import android.os.SystemClock;
|
|
|
|
|
-
|
|
|
|
|
-import org.yuzu.yuzu_emu.BuildConfig;
|
|
|
|
|
-import org.yuzu.yuzu_emu.YuzuApplication;
|
|
|
|
|
-import org.yuzu.yuzu_emu.R;
|
|
|
|
|
-import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile;
|
|
|
|
|
-import org.yuzu.yuzu_emu.model.GameDatabase;
|
|
|
|
|
-import org.yuzu.yuzu_emu.utils.AddDirectoryHelper;
|
|
|
|
|
-
|
|
|
|
|
-public final class MainPresenter {
|
|
|
|
|
- public static final int REQUEST_ADD_DIRECTORY = 1;
|
|
|
|
|
- public static final int REQUEST_INSTALL_KEYS = 2;
|
|
|
|
|
- public static final int REQUEST_SELECT_GPU_DRIVER = 3;
|
|
|
|
|
- private final MainView mView;
|
|
|
|
|
- private String mDirToAdd;
|
|
|
|
|
- private long mLastClickTime = 0;
|
|
|
|
|
-
|
|
|
|
|
- public MainPresenter(MainView view) {
|
|
|
|
|
- mView = view;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void onCreate() {
|
|
|
|
|
- String versionName = BuildConfig.VERSION_NAME;
|
|
|
|
|
- mView.setVersionString(versionName);
|
|
|
|
|
- refreshGameList();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void launchFileListActivity(int request) {
|
|
|
|
|
- if (mView != null) {
|
|
|
|
|
- mView.launchFileListActivity(request);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public boolean handleOptionSelection(int itemId) {
|
|
|
|
|
- // Double-click prevention, using threshold of 500 ms
|
|
|
|
|
- if (SystemClock.elapsedRealtime() - mLastClickTime < 500) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- mLastClickTime = SystemClock.elapsedRealtime();
|
|
|
|
|
-
|
|
|
|
|
- switch (itemId) {
|
|
|
|
|
- case R.id.menu_settings_core:
|
|
|
|
|
- mView.launchSettingsActivity(SettingsFile.FILE_NAME_CONFIG);
|
|
|
|
|
- return true;
|
|
|
|
|
-
|
|
|
|
|
- case R.id.button_add_directory:
|
|
|
|
|
- launchFileListActivity(REQUEST_ADD_DIRECTORY);
|
|
|
|
|
- return true;
|
|
|
|
|
-
|
|
|
|
|
- case R.id.button_install_keys:
|
|
|
|
|
- launchFileListActivity(REQUEST_INSTALL_KEYS);
|
|
|
|
|
- return true;
|
|
|
|
|
-
|
|
|
|
|
- case R.id.button_select_gpu_driver:
|
|
|
|
|
- launchFileListActivity(REQUEST_SELECT_GPU_DRIVER);
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void addDirIfNeeded(AddDirectoryHelper helper) {
|
|
|
|
|
- if (mDirToAdd != null) {
|
|
|
|
|
- helper.addDirectory(mDirToAdd, mView::refresh);
|
|
|
|
|
-
|
|
|
|
|
- mDirToAdd = null;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void onDirectorySelected(String dir) {
|
|
|
|
|
- mDirToAdd = dir;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void refreshGameList() {
|
|
|
|
|
- GameDatabase databaseHelper = YuzuApplication.databaseHelper;
|
|
|
|
|
- databaseHelper.scanLibrary(databaseHelper.getWritableDatabase());
|
|
|
|
|
- mView.refresh();
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|