mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 11:33:06 +00:00
Fix dialog rundown issues causing spurious crashes
This commit is contained in:
parent
e2663f06ba
commit
d428f342f7
@ -11,7 +11,7 @@ public class Dialog implements Runnable {
|
|||||||
private Activity activity;
|
private Activity activity;
|
||||||
private boolean endAfterDismiss;
|
private boolean endAfterDismiss;
|
||||||
|
|
||||||
AlertDialog alert;
|
private AlertDialog alert;
|
||||||
|
|
||||||
private static ArrayList<Dialog> rundownDialogs = new ArrayList<Dialog>();
|
private static ArrayList<Dialog> rundownDialogs = new ArrayList<Dialog>();
|
||||||
|
|
||||||
@ -25,13 +25,15 @@ public class Dialog implements Runnable {
|
|||||||
|
|
||||||
public static void closeDialogs()
|
public static void closeDialogs()
|
||||||
{
|
{
|
||||||
for (Dialog d : rundownDialogs) {
|
synchronized (rundownDialogs) {
|
||||||
if (d.alert.isShowing()) {
|
for (Dialog d : rundownDialogs) {
|
||||||
d.alert.dismiss();
|
if (d.alert.isShowing()) {
|
||||||
|
d.alert.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rundownDialogs.clear();
|
rundownDialogs.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void displayDialog(Activity activity, String title, String message, boolean endAfterDismiss)
|
public static void displayDialog(Activity activity, String title, String message, boolean endAfterDismiss)
|
||||||
@ -54,16 +56,21 @@ public class Dialog implements Runnable {
|
|||||||
|
|
||||||
alert.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
|
alert.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
alert.dismiss();
|
synchronized (rundownDialogs) {
|
||||||
rundownDialogs.remove(this);
|
rundownDialogs.remove(this);
|
||||||
|
alert.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
if (endAfterDismiss)
|
if (endAfterDismiss) {
|
||||||
activity.finish();
|
activity.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
rundownDialogs.add(this);
|
synchronized (rundownDialogs) {
|
||||||
alert.show();
|
rundownDialogs.add(this);
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,15 @@ public class SpinnerDialog implements Runnable,OnCancelListener {
|
|||||||
|
|
||||||
public static void closeDialogs()
|
public static void closeDialogs()
|
||||||
{
|
{
|
||||||
for (SpinnerDialog d : rundownDialogs) {
|
synchronized (rundownDialogs) {
|
||||||
if (d.progress.isShowing()) {
|
for (SpinnerDialog d : rundownDialogs) {
|
||||||
d.progress.dismiss();
|
if (d.progress.isShowing()) {
|
||||||
|
d.progress.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rundownDialogs.clear();
|
rundownDialogs.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dismiss()
|
public void dismiss()
|
||||||
@ -85,18 +87,27 @@ public class SpinnerDialog implements Runnable,OnCancelListener {
|
|||||||
progress.setCancelable(false);
|
progress.setCancelable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.show();
|
synchronized (rundownDialogs) {
|
||||||
|
rundownDialogs.add(this);
|
||||||
|
progress.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (progress.isShowing()) {
|
synchronized (rundownDialogs) {
|
||||||
progress.dismiss();
|
if (rundownDialogs.remove(this) && progress.isShowing()) {
|
||||||
|
progress.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
synchronized (rundownDialogs) {
|
||||||
|
rundownDialogs.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
// This will only be called if finish was true, so we don't need to check again
|
// This will only be called if finish was true, so we don't need to check again
|
||||||
activity.finish();
|
activity.finish();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user