mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-09-29 23:54:53 +00:00
Keep track of all AlertDialog objects to properly dispose of them upon backgrounding
This commit is contained in:
parent
9c475b58eb
commit
104c0bbe6e
@ -199,7 +199,8 @@ public abstract class Apple2AbstractMenu implements Apple2MenuView {
|
|||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.show();
|
AlertDialog dialog = builder.create();
|
||||||
|
activity.registerAndShowDialog(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ImageView _addPopupIcon(Apple2Activity activity, IMenuEnum setting, View convertView) {
|
protected static ImageView _addPopupIcon(Apple2Activity activity, IMenuEnum setting, View convertView) {
|
||||||
|
@ -44,8 +44,7 @@ public class Apple2Activity extends Activity {
|
|||||||
private Apple2SplashScreen mSplashScreen = null;
|
private Apple2SplashScreen mSplashScreen = null;
|
||||||
private Apple2MainMenu mMainMenu = null;
|
private Apple2MainMenu mMainMenu = null;
|
||||||
private ArrayList<Apple2MenuView> mMenuStack = new ArrayList<Apple2MenuView>();
|
private ArrayList<Apple2MenuView> mMenuStack = new ArrayList<Apple2MenuView>();
|
||||||
private AlertDialog mQuitDialog = null;
|
private ArrayList<AlertDialog> mAlertDialogs = new ArrayList<AlertDialog>();
|
||||||
private AlertDialog mRebootDialog = null;
|
|
||||||
|
|
||||||
private int mWidth = 0;
|
private int mWidth = 0;
|
||||||
private int mHeight = 0;
|
private int mHeight = 0;
|
||||||
@ -246,7 +245,6 @@ public class Apple2Activity extends Activity {
|
|||||||
|
|
||||||
// Apparently not good to leave popup/dialog windows showing when backgrounding.
|
// Apparently not good to leave popup/dialog windows showing when backgrounding.
|
||||||
// Dismiss these popups to avoid android.view.WindowLeaked issues
|
// Dismiss these popups to avoid android.view.WindowLeaked issues
|
||||||
// TODO FIXME : need to test/fix other popups generated in other menus ...
|
|
||||||
dismissAllMenus();
|
dismissAllMenus();
|
||||||
|
|
||||||
mSplashScreen = null;
|
mSplashScreen = null;
|
||||||
@ -304,18 +302,17 @@ public class Apple2Activity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private void printSamples(MotionEvent ev) {
|
private void printSamples(MotionEvent ev) {
|
||||||
final int historySize = ev.getHistorySize();
|
final int historySize = ev.getHistorySize();
|
||||||
final int pointerCount = ev.getPointerCount();
|
final int pointerCount = ev.getPointerCount();
|
||||||
|
|
||||||
/*
|
|
||||||
for (int h = 0; h < historySize; h++) {
|
for (int h = 0; h < historySize; h++) {
|
||||||
Log.d(TAG, "Event "+ev.getAction().toString()+" at historical time "+ev.getHistoricalEventTime(h)+" :");
|
Log.d(TAG, "Event "+ev.getAction().toString()+" at historical time "+ev.getHistoricalEventTime(h)+" :");
|
||||||
for (int p = 0; p < pointerCount; p++) {
|
for (int p = 0; p < pointerCount; p++) {
|
||||||
Log.d(TAG, " pointer "+ev.getPointerId(p)+": ("+ev.getHistoricalX(p, h)+","+ev.getHistoricalY(p, h)+")");
|
Log.d(TAG, " pointer "+ev.getPointerId(p)+": ("+ev.getHistoricalX(p, h)+","+ev.getHistoricalY(p, h)+")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
int pointerIndex = ev.getActionIndex();
|
int pointerIndex = ev.getActionIndex();
|
||||||
|
|
||||||
Log.d(TAG, "Event " + actionToString(ev.getActionMasked()) + " for " + pointerIndex + " at time " + ev.getEventTime() + " :");
|
Log.d(TAG, "Event " + actionToString(ev.getActionMasked()) + " for " + pointerIndex + " at time " + ev.getEventTime() + " :");
|
||||||
@ -323,6 +320,7 @@ public class Apple2Activity extends Activity {
|
|||||||
Log.d(TAG, " pointer " + ev.getPointerId(p) + ": (" + ev.getX(p) + "," + ev.getY(p) + ")");
|
Log.d(TAG, " pointer " + ev.getPointerId(p) + ": (" + ev.getX(p) + "," + ev.getY(p) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
@ -462,6 +460,11 @@ public class Apple2Activity extends Activity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerAndShowDialog(AlertDialog dialog) {
|
||||||
|
dialog.show();
|
||||||
|
mAlertDialogs.add(dialog);
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void pushApple2View(Apple2MenuView apple2MenuView) {
|
public synchronized void pushApple2View(Apple2MenuView apple2MenuView) {
|
||||||
mMenuStack.add(apple2MenuView);
|
mMenuStack.add(apple2MenuView);
|
||||||
View menuView = apple2MenuView.getView();
|
View menuView = apple2MenuView.getView();
|
||||||
@ -506,12 +509,11 @@ public class Apple2Activity extends Activity {
|
|||||||
if (mMainMenu != null) {
|
if (mMainMenu != null) {
|
||||||
mMainMenu.dismiss();
|
mMainMenu.dismiss();
|
||||||
}
|
}
|
||||||
if (mQuitDialog != null && mQuitDialog.isShowing()) {
|
|
||||||
mQuitDialog.dismiss();
|
for (AlertDialog dialog : mAlertDialogs) {
|
||||||
}
|
dialog.dismiss();
|
||||||
if (mRebootDialog != null && mRebootDialog.isShowing()) {
|
|
||||||
mRebootDialog.dismiss();
|
|
||||||
}
|
}
|
||||||
|
mAlertDialogs.clear();
|
||||||
|
|
||||||
// Get rid of the menu hierarchy
|
// Get rid of the menu hierarchy
|
||||||
Apple2MenuView apple2MenuView;
|
Apple2MenuView apple2MenuView;
|
||||||
@ -541,6 +543,7 @@ public class Apple2Activity extends Activity {
|
|||||||
|
|
||||||
// if no more views on menu stack, resume emulation
|
// if no more views on menu stack, resume emulation
|
||||||
if (mMenuStack.size() == 0) {
|
if (mMenuStack.size() == 0) {
|
||||||
|
dismissAllMenus();
|
||||||
nativeOnResume(/*isSystemResume:*/false);
|
nativeOnResume(/*isSystemResume:*/false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,8 +562,7 @@ public class Apple2Activity extends Activity {
|
|||||||
|
|
||||||
public void maybeQuitApp() {
|
public void maybeQuitApp() {
|
||||||
nativeOnPause(false);
|
nativeOnPause(false);
|
||||||
if (mQuitDialog == null) {
|
AlertDialog quitDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.quit_really).setMessage(R.string.quit_warning).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
mQuitDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.quit_really).setMessage(R.string.quit_warning).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
nativeOnQuit();
|
nativeOnQuit();
|
||||||
@ -578,45 +580,18 @@ public class Apple2Activity extends Activity {
|
|||||||
}.run();
|
}.run();
|
||||||
}
|
}
|
||||||
}).setNegativeButton(R.string.no, null).create();
|
}).setNegativeButton(R.string.no, null).create();
|
||||||
/*mQuitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
registerAndShowDialog(quitDialog);
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
nativeOnResume(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mQuitDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
||||||
@Override
|
|
||||||
public void onDismiss(DialogInterface dialog) {
|
|
||||||
nativeOnResume(false);
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
|
||||||
mQuitDialog.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void maybeReboot() {
|
public void maybeReboot() {
|
||||||
nativeOnPause(false);
|
nativeOnPause(false);
|
||||||
if (mRebootDialog == null) {
|
AlertDialog rebootDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.reboot_really).setMessage(R.string.reboot_warning).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
mRebootDialog = new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher).setCancelable(true).setTitle(R.string.reboot_really).setMessage(R.string.reboot_warning).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
nativeReboot();
|
nativeReboot();
|
||||||
Apple2Activity.this.mMainMenu.dismiss();
|
Apple2Activity.this.mMainMenu.dismiss();
|
||||||
}
|
}
|
||||||
}).setNegativeButton(R.string.no, null).create();
|
}).setNegativeButton(R.string.no, null).create();
|
||||||
/*mRebootDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
registerAndShowDialog(rebootDialog);
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
nativeOnResume(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mRebootDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
||||||
@Override
|
|
||||||
public void onDismiss(DialogInterface dialog) {
|
|
||||||
nativeOnResume(false);
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
|
||||||
mRebootDialog.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,8 @@ public class Apple2DisksMenu implements Apple2MenuView {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.show();
|
AlertDialog dialog = builder.create();
|
||||||
|
mActivity.registerAndShowDialog(dialog);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -928,7 +928,7 @@ public enum Apple2Preferences {
|
|||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
}).create();
|
}).create();
|
||||||
dialog.show();
|
activity.registerAndShowDialog(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAllKeypadKeys(Apple2Activity activity) {
|
public static void loadAllKeypadKeys(Apple2Activity activity) {
|
||||||
|
@ -287,7 +287,8 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
|||||||
Apple2Preferences.resetPreferences(activity);
|
Apple2Preferences.resetPreferences(activity);
|
||||||
}
|
}
|
||||||
}).setNegativeButton(R.string.no, null);
|
}).setNegativeButton(R.string.no, null);
|
||||||
builder.show();
|
AlertDialog dialog = builder.create();
|
||||||
|
activity.registerAndShowDialog(dialog);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user