Skip to content

Commit

Permalink
Android: Disallow multiple launcher activities
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebola16 committed Jun 16, 2020
1 parent 4c64e18 commit 1e6925e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public final class EmulationActivity extends AppCompatActivity
private boolean mDeviceHasTouchScreen;
private boolean mMenuVisible;

private static boolean sIgnoreLaunchRequests = false;
private static boolean sIsGameCubeGame;

private boolean activityRecreated;
Expand Down Expand Up @@ -196,6 +197,11 @@ private static String[] scanForSecondDisc(GameFile gameFile)

public static void launch(FragmentActivity activity, GameFile gameFile)
{
if (sIgnoreLaunchRequests)
return;

sIgnoreLaunchRequests = true;

Intent launcher = new Intent(activity, EmulationActivity.class);

launcher.putExtra(EXTRA_SELECTED_GAMES, scanForSecondDisc(gameFile));
Expand All @@ -207,6 +213,11 @@ public static void launch(FragmentActivity activity, GameFile gameFile)

public static void launchFile(FragmentActivity activity, String[] filePaths)
{
if (sIgnoreLaunchRequests)
return;

sIgnoreLaunchRequests = true;

Intent launcher = new Intent(activity, EmulationActivity.class);
launcher.putExtra(EXTRA_SELECTED_GAMES, filePaths);

Expand Down Expand Up @@ -237,6 +248,11 @@ public static void launchFile(FragmentActivity activity, String[] filePaths)
activity.startActivity(launcher);
}

public static void stopIgnoringLaunchRequests()
{
sIgnoreLaunchRequests = false;
}

public static void clearWiimoteNewIniLinkedPreferences(Context context)
{
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ private void runWithValidSurface()
Log.debug("[EmulationFragment] Starting emulation thread.");
NativeLibrary.Run(mGamePaths);
}
EmulationActivity.stopIgnoringLaunchRequests();
}, "NativeEmulation");
emulationThread.start();
}
Expand Down

0 comments on commit 1e6925e

Please sign in to comment.