Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,30 @@ public void onClick(DialogInterface dialog, int which)

public void finalStartup()
{
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
Intent retro = new Intent(this, RetroActivityFuture.class);

retro.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

startRetroActivity(
retro,
null,
prefs.getString("libretro_path", getApplicationInfo().dataDir + "/cores/"),
UserPreferences.getDefaultConfigPath(this),
Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD),
getApplicationInfo().dataDir,
getApplicationInfo().sourceDir);

if (RetroActivityFuture.isRunning) {
// RetroActivity is already running - just bring it to front
retro.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
} else {
// RetroActivity not running - full setup with parameters
retro.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

startRetroActivity(
retro,
null,
prefs.getString("libretro_path", getApplicationInfo().dataDir + "/cores/"),
UserPreferences.getDefaultConfigPath(this),
Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD),
getApplicationInfo().dataDir,
getApplicationInfo().sourceDir);
}

startActivity(retro);
finish();
}


@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

public final class RetroActivityFuture extends RetroActivityCamera {

// Tracks activity lifecycle state for MainMenuActivity resume detection
public static volatile boolean isRunning = false;

// If set to true then RetroArch will completely exit when it loses focus
private boolean quitfocus = false;

Expand Down Expand Up @@ -55,7 +58,8 @@ public void handleMessage(Message msg) {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


isRunning = true;
mDecorView = getWindow().getDecorView();

// If QUITFOCUS parameter is provided then enable that Retroarch quits when focus is lost
Expand All @@ -66,7 +70,7 @@ public void onCreate(Bundle savedInstanceState) {
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);

// Check if this intent contains game launch parameters
// Extract game parameters from new intent
String newRom = intent.getStringExtra("ROM");
String newCore = intent.getStringExtra("LIBRETRO");

Expand All @@ -75,17 +79,11 @@ public void onNewIntent(Intent intent) {
String currentRom = currentIntent != null ? currentIntent.getStringExtra("ROM") : null;
String currentCore = currentIntent != null ? currentIntent.getStringExtra("LIBRETRO") : null;

// Check if we're trying to launch different content
boolean isDifferentContent = false;
if (newRom != null && !newRom.equals(currentRom)) {
isDifferentContent = true;
}
if (newCore != null && !newCore.equals(currentCore)) {
isDifferentContent = true;
}

if (isDifferentContent) {
// Exit cleanly and let the system restart us with new content
// Check if we're trying to launch different content
if ((newRom != null && !newRom.equals(currentRom)) ||
(newCore != null && !newCore.equals(currentCore))) {
// Different game content - exit cleanly and let launcher restart us
finish();
System.exit(0);
} else {
Expand All @@ -94,7 +92,6 @@ public void onNewIntent(Intent intent) {
}
}


@Override
public void onResume() {
super.onResume();
Expand Down Expand Up @@ -134,6 +131,12 @@ public void onStop() {
if (quitfocus) System.exit(0);
}

@Override
public void onDestroy() {
super.onDestroy();
isRunning = false;
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
Expand Down
Loading