@@ -511,59 +511,54 @@ public static boolean displayAlertMsg(final String caption, final String text,
511511 Log .error ("[NativeLibrary] Alert: " + text );
512512 final EmulationActivity emulationActivity = sEmulationActivity .get ();
513513 boolean result = false ;
514- if (isWarning && emulationActivity != null && emulationActivity .isIgnoringWarnings ())
514+
515+ // We can't use AlertMessages unless we have a non-null activity reference
516+ // and are allowed to block. As a fallback, we can use toasts.
517+ if (emulationActivity == null || nonBlocking )
515518 {
516- return true ;
519+ new Handler (Looper .getMainLooper ()).post (
520+ () -> Toast .makeText (DolphinApplication .getAppContext (), text , Toast .LENGTH_LONG )
521+ .show ());
517522 }
518523 else
519524 {
520- // We can't use AlertMessages unless we have a non-null activity reference
521- // and are allowed to block. As a fallback, we can use toasts.
522- if (emulationActivity == null || nonBlocking )
523- {
524- new Handler (Looper .getMainLooper ()).post (
525- () -> Toast .makeText (DolphinApplication .getAppContext (), text , Toast .LENGTH_LONG )
526- .show ());
527- }
528- else
529- {
530- sIsShowingAlertMessage = true ;
525+ sIsShowingAlertMessage = true ;
531526
532- emulationActivity .runOnUiThread (() ->
527+ emulationActivity .runOnUiThread (() ->
528+ {
529+ FragmentManager fragmentManager = emulationActivity .getSupportFragmentManager ();
530+ if (fragmentManager .isStateSaved ())
533531 {
534- FragmentManager fragmentManager = emulationActivity .getSupportFragmentManager ();
535- if (fragmentManager .isStateSaved ())
536- {
537- // The activity is being destroyed, so we can't use it to display an AlertMessage.
538- // Fall back to a toast.
539- Toast .makeText (emulationActivity , text , Toast .LENGTH_LONG ).show ();
540- NotifyAlertMessageLock ();
541- }
542- else
543- {
544- AlertMessage .newInstance (caption , text , yesNo , isWarning )
545- .show (fragmentManager , "AlertMessage" );
546- }
547- });
548-
549- // Wait for the lock to notify that it is complete.
550- synchronized (sAlertMessageLock )
532+ // The activity is being destroyed, so we can't use it to display an AlertMessage.
533+ // Fall back to a toast.
534+ Toast .makeText (emulationActivity , text , Toast .LENGTH_LONG ).show ();
535+ NotifyAlertMessageLock ();
536+ }
537+ else
551538 {
552- try
553- {
554- sAlertMessageLock .wait ();
555- }
556- catch (Exception ignored )
557- {
558- }
539+ AlertMessage .newInstance (caption , text , yesNo , isWarning )
540+ .show (fragmentManager , "AlertMessage" );
559541 }
542+ });
560543
561- if (yesNo )
544+ // Wait for the lock to notify that it is complete.
545+ synchronized (sAlertMessageLock )
546+ {
547+ try
562548 {
563- result = AlertMessage . getAlertResult ();
549+ sAlertMessageLock . wait ();
564550 }
551+ catch (Exception ignored )
552+ {
553+ }
554+ }
555+
556+ if (yesNo )
557+ {
558+ result = AlertMessage .getAlertResult ();
565559 }
566560 }
561+
567562 sIsShowingAlertMessage = false ;
568563 return result ;
569564 }
0 commit comments