mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-12-28 12:33:04 +00:00
Avoid another UI race exposed by NVIDIA Shield Portable
- Use AtomicBoolean to avoid spurious extra taps/clicks/presses
This commit is contained in:
parent
3ff877d80c
commit
7dd0f0b3cf
@ -513,15 +513,25 @@ public class Apple2Activity extends Activity {
|
|||||||
|
|
||||||
final String quickSavePath = Apple2DisksMenu.getDataDir(this) + File.separator + SAVE_FILE;
|
final String quickSavePath = Apple2DisksMenu.getDataDir(this) + File.separator + SAVE_FILE;
|
||||||
|
|
||||||
|
final AtomicBoolean selectionAlreadyHandled = new AtomicBoolean(false);
|
||||||
|
|
||||||
AlertDialog saveRestoreDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.saverestore).setMessage(R.string.saverestore_choice).setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
|
AlertDialog saveRestoreDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.saverestore).setMessage(R.string.saverestore_choice).setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (!selectionAlreadyHandled.compareAndSet(false, true)) {
|
||||||
|
Log.v(TAG, "OMG, avoiding nasty UI race in save/restore onClick()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Apple2Activity.this.nativeSaveState(quickSavePath);
|
Apple2Activity.this.nativeSaveState(quickSavePath);
|
||||||
Apple2Activity.this.mMainMenu.dismiss();
|
Apple2Activity.this.mMainMenu.dismiss();
|
||||||
}
|
}
|
||||||
}).setNeutralButton(R.string.restore, new DialogInterface.OnClickListener() {
|
}).setNeutralButton(R.string.restore, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (!selectionAlreadyHandled.compareAndSet(false, true)) {
|
||||||
|
Log.v(TAG, "OMG, avoiding nasty UI race in save/restore onClick()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String jsonData = Apple2Activity.this.nativeLoadState(quickSavePath);
|
String jsonData = Apple2Activity.this.nativeLoadState(quickSavePath);
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user