mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-17 03:15:39 +00:00
Android: Fix disabling save state on exit not working
This commit is contained in:
parent
907bba19c0
commit
671033fdd2
|
@ -36,6 +36,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
*/
|
*/
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private boolean mWasDestroyed = false;
|
private boolean mWasDestroyed = false;
|
||||||
|
private boolean mStopRequested = false;
|
||||||
private boolean mWasPausedOnSurfaceLoss = false;
|
private boolean mWasPausedOnSurfaceLoss = false;
|
||||||
private boolean mApplySettingsOnSurfaceRestored = false;
|
private boolean mApplySettingsOnSurfaceRestored = false;
|
||||||
private String mGameTitle = null;
|
private String mGameTitle = null;
|
||||||
|
@ -101,7 +102,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
public void onEmulationStopped() {
|
public void onEmulationStopped() {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
AndroidHostInterface.getInstance().stopEmulationThread();
|
AndroidHostInterface.getInstance().stopEmulationThread();
|
||||||
if (!mWasDestroyed)
|
if (!mWasDestroyed && !mStopRequested)
|
||||||
finish();
|
finish();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,8 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
Log.i("EmulationActivity", "Surface destroyed");
|
Log.i("EmulationActivity", "Surface destroyed");
|
||||||
|
|
||||||
// Save the resume state in case we never get back again...
|
// Save the resume state in case we never get back again...
|
||||||
AndroidHostInterface.getInstance().saveResumeState(true);
|
if (!mStopRequested)
|
||||||
|
AndroidHostInterface.getInstance().saveResumeState(true);
|
||||||
|
|
||||||
mWasPausedOnSurfaceLoss = AndroidHostInterface.getInstance().isEmulationThreadPaused();
|
mWasPausedOnSurfaceLoss = AndroidHostInterface.getInstance().isEmulationThreadPaused();
|
||||||
AndroidHostInterface.getInstance().pauseEmulationThread(true);
|
AndroidHostInterface.getInstance().pauseEmulationThread(true);
|
||||||
|
@ -292,6 +294,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
|
|
||||||
case 4: // Quit
|
case 4: // Quit
|
||||||
{
|
{
|
||||||
|
mStopRequested = true;
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,11 @@ public class MainActivity extends AppCompatActivity {
|
||||||
private ListView mGameListView;
|
private ListView mGameListView;
|
||||||
private boolean mHasExternalStoragePermissions = false;
|
private boolean mHasExternalStoragePermissions = false;
|
||||||
|
|
||||||
|
private boolean shouldResumeStateByDefault() {
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
return prefs.getBoolean("Main/SaveStateOnExit", true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -71,7 +76,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
findViewById(R.id.fab_resume).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.fab_resume).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
startEmulation(null, true);
|
startEmulation(null, shouldResumeStateByDefault());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -82,7 +87,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
mGameListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
mGameListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
startEmulation(mGameList.getEntry(position).getPath(), true);
|
startEmulation(mGameList.getEntry(position).getPath(), shouldResumeStateByDefault());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mGameListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
mGameListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||||
|
|
Loading…
Reference in a new issue