mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 22:05:38 +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 boolean mWasDestroyed = false;
|
||||
private boolean mStopRequested = false;
|
||||
private boolean mWasPausedOnSurfaceLoss = false;
|
||||
private boolean mApplySettingsOnSurfaceRestored = false;
|
||||
private String mGameTitle = null;
|
||||
|
@ -101,7 +102,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
|||
public void onEmulationStopped() {
|
||||
runOnUiThread(() -> {
|
||||
AndroidHostInterface.getInstance().stopEmulationThread();
|
||||
if (!mWasDestroyed)
|
||||
if (!mWasDestroyed && !mStopRequested)
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
@ -162,7 +163,8 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
|||
Log.i("EmulationActivity", "Surface destroyed");
|
||||
|
||||
// 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();
|
||||
AndroidHostInterface.getInstance().pauseEmulationThread(true);
|
||||
|
@ -292,6 +294,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
|||
|
||||
case 4: // Quit
|
||||
{
|
||||
mStopRequested = true;
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,11 @@ public class MainActivity extends AppCompatActivity {
|
|||
private ListView mGameListView;
|
||||
private boolean mHasExternalStoragePermissions = false;
|
||||
|
||||
private boolean shouldResumeStateByDefault() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
return prefs.getBoolean("Main/SaveStateOnExit", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -71,7 +76,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
findViewById(R.id.fab_resume).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
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() {
|
||||
@Override
|
||||
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() {
|
||||
|
|
Loading…
Reference in a new issue