Merge pull request #12345 from minhaferzz/startup-handler

Android: Fix issue when launching a game when Dolphin is not open
This commit is contained in:
Mai 2023-12-05 03:10:41 -05:00 committed by GitHub
commit 2199dd26bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -1066,16 +1066,16 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider {
} }
@JvmStatic @JvmStatic
fun launch(activity: FragmentActivity, filePaths: Array<String>, riivolution: Boolean) { fun launch(activity: FragmentActivity, filePaths: Array<String>, riivolution: Boolean, fromIntent: Boolean = false) {
if (ignoreLaunchRequests) if (ignoreLaunchRequests)
return return
performLaunchChecks(activity) { launchWithoutChecks(activity, filePaths, riivolution) } performLaunchChecks(activity, fromIntent) { launchWithoutChecks(activity, filePaths, riivolution) }
} }
@JvmStatic @JvmStatic
fun launch(activity: FragmentActivity, filePath: String, riivolution: Boolean) = fun launch(activity: FragmentActivity, filePath: String, riivolution: Boolean, fromIntent: Boolean = false) =
launch(activity, arrayOf(filePath), riivolution) launch(activity, arrayOf(filePath), riivolution, fromIntent)
private fun launchWithoutChecks( private fun launchWithoutChecks(
activity: FragmentActivity, activity: FragmentActivity,
@ -1089,8 +1089,11 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider {
activity.startActivity(launcher) activity.startActivity(launcher)
} }
private fun performLaunchChecks(activity: FragmentActivity, continueCallback: Runnable) { private fun performLaunchChecks(activity: FragmentActivity, fromIntent: Boolean, continueCallback: Runnable) {
AfterDirectoryInitializationRunner().runWithLifecycle(activity) { AfterDirectoryInitializationRunner().runWithLifecycle(activity) {
if (fromIntent) {
activity.finish()
}
if (!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DEFAULT_ISO) || if (!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DEFAULT_ISO) ||
!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_FS_PATH) || !FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_FS_PATH) ||
!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DUMP_PATH) || !FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DUMP_PATH) ||
@ -1129,7 +1132,7 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider {
if (ignoreLaunchRequests) if (ignoreLaunchRequests)
return return
performLaunchChecks(activity) { launchSystemMenuWithoutChecks(activity) } performLaunchChecks(activity, false) { launchSystemMenuWithoutChecks(activity) }
} }
private fun launchSystemMenuWithoutChecks(activity: FragmentActivity) { private fun launchSystemMenuWithoutChecks(activity: FragmentActivity) {

View File

@ -37,8 +37,7 @@ public final class StartupHandler
if (gamesToLaunch != null && gamesToLaunch.length > 0) if (gamesToLaunch != null && gamesToLaunch.length > 0)
{ {
// Start the emulation activity, send the ISO passed in and finish the main activity // Start the emulation activity, send the ISO passed in and finish the main activity
EmulationActivity.launch(parent, gamesToLaunch, false); EmulationActivity.launch(parent, gamesToLaunch, false, true);
parent.finish();
} }
} }