summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-10-18 16:06:46 +0200
committerJosJuice <josjuice@gmail.com>2020-10-18 16:06:46 +0200
commit8d91b4ea8c2dafeffd01d5bea0ac30113cd55222 (patch)
tree759f73c91a6ff81db2629ab35cd2ac14cccefdb3 /Source/Android/app/src/main/java
parent16f5a50cfc0a49ee0f6b09382b40e89dcb8b5535 (diff)
Android: Show alert messages as toasts outside of emulation
It would be difficult to use the AlertMessage class for messages that need to be showed outside of emulation, but showing them as toasts is better than not showing them.
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java20
1 files changed, 9 insertions, 11 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
index 44c1ab4f15..d37856d402 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
@@ -6,6 +6,8 @@
package org.dolphinemu.dolphinemu;
+import android.os.Handler;
+import android.os.Looper;
import android.util.DisplayMetrics;
import android.view.Surface;
import android.widget.Toast;
@@ -451,23 +453,19 @@ public final class NativeLibrary
Log.error("[NativeLibrary] Alert: " + text);
final EmulationActivity emulationActivity = sEmulationActivity.get();
boolean result = false;
- if (emulationActivity == null)
- {
- Log.warning("[NativeLibrary] EmulationActivity is null, can't do panic alert.");
- }
- else if (emulationActivity.isIgnoringWarnings() && isWarning)
+ if (isWarning && emulationActivity != null && emulationActivity.isIgnoringWarnings())
{
return true;
}
else
{
- // AlertMessages while the core is booting will deadlock when WaitUntilDoneBooting is called.
- // Report the AlertMessage text as a toast instead.
- if (IsBooting())
+ // AlertMessages while the core is booting will deadlock if WaitUntilDoneBooting is called.
+ // We also can't use AlertMessages unless we have a non-null activity reference.
+ // As a fallback, we use toasts instead.
+ if (emulationActivity == null || IsBooting())
{
- emulationActivity.runOnUiThread(
- () -> Toast.makeText(emulationActivity.getApplicationContext(), text,
- Toast.LENGTH_LONG)
+ new Handler(Looper.getMainLooper()).post(
+ () -> Toast.makeText(DolphinApplication.getAppContext(), text, Toast.LENGTH_LONG)
.show());
}
else