mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-12-26 15:29:19 +00:00
Avoid nasty UI race manifesting on NVIDIA Shield Portable
- For some reason this device has really slow Java UI, so it exposed a case where spammy touch resulted in two save/restore popups and a subsequent assert on the native side if you saved while the emulation was resumed.
This commit is contained in:
parent
1e573c34ad
commit
e5e2f98835
@ -28,6 +28,8 @@ import android.widget.TextView;
|
||||
|
||||
import org.deadc0de.apple2ix.basic.R;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class Apple2MainMenu {
|
||||
|
||||
private final static int MENU_INSET = 20;
|
||||
@ -37,6 +39,9 @@ public class Apple2MainMenu {
|
||||
private Apple2View mParentView = null;
|
||||
private PopupWindow mMainMenuPopup = null;
|
||||
|
||||
private AtomicBoolean mShowingRebootQuit = new AtomicBoolean(false);
|
||||
private AtomicBoolean mShowingSaveRestore = new AtomicBoolean(false);
|
||||
|
||||
public Apple2MainMenu(Apple2Activity activity, Apple2View parent) {
|
||||
mActivity = activity;
|
||||
mParentView = parent;
|
||||
@ -74,6 +79,10 @@ public class Apple2MainMenu {
|
||||
return ctx.getResources().getString(R.string.saverestore_summary);
|
||||
}
|
||||
@Override public void handleSelection(Apple2MainMenu mainMenu) {
|
||||
if (!mainMenu.mShowingSaveRestore.compareAndSet(false, true)) {
|
||||
Log.d(TAG, "OMG, avoiding nasty UI race around save/restore");
|
||||
return;
|
||||
}
|
||||
mainMenu.mActivity.maybeSaveRestore();
|
||||
}
|
||||
},
|
||||
@ -85,6 +94,10 @@ public class Apple2MainMenu {
|
||||
return "";
|
||||
}
|
||||
@Override public void handleSelection(Apple2MainMenu mainMenu) {
|
||||
if (!mainMenu.mShowingRebootQuit.compareAndSet(false, true)) {
|
||||
Log.d(TAG, "OMG, avoiding nasty UI race around quit/reboot");
|
||||
return;
|
||||
}
|
||||
mainMenu.mActivity.maybeRebootQuit();
|
||||
}
|
||||
};
|
||||
@ -163,7 +176,7 @@ public class Apple2MainMenu {
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
Apple2MainMenu.this.mActivity.maybeResumeCPU();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -184,6 +197,9 @@ public class Apple2MainMenu {
|
||||
return;
|
||||
}
|
||||
|
||||
mShowingRebootQuit.set(false);
|
||||
mShowingSaveRestore.set(false);
|
||||
|
||||
mActivity.nativeEmulationPause();
|
||||
|
||||
mMainMenuPopup.showAtLocation(mParentView, Gravity.CENTER, 0, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user