1
0
Fork 0

fixed Toast message not appearing when diplaying them from async context

This commit is contained in:
sspanak 2025-05-10 13:35:58 +03:00 committed by Dimo Karaivanov
parent b88957ff5f
commit 2c77c5aa96

View file

@ -4,6 +4,7 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.inputmethodservice.InputMethodService; import android.inputmethodservice.InputMethodService;
import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.Toast; import android.widget.Toast;
@ -57,10 +58,7 @@ public class UI {
public static void toastFromAsync(Context context, CharSequence msg) { public static void toastFromAsync(Context context, CharSequence msg) {
if (Looper.myLooper() == null) { new Handler(Looper.getMainLooper()).post(() -> toast(context, msg));
Looper.prepare();
}
toast(context, msg);
} }
@ -70,10 +68,7 @@ public class UI {
public static void toastFromAsync(Context context, int resourceId) { public static void toastFromAsync(Context context, int resourceId) {
if (Looper.myLooper() == null) { new Handler(Looper.getMainLooper()).post(() -> toast(context, resourceId));
Looper.prepare();
}
toast(context, resourceId);
} }
@ -88,10 +83,7 @@ public class UI {
public static void toastLongFromAsync(Context context, CharSequence msg) { public static void toastLongFromAsync(Context context, CharSequence msg) {
if (Looper.myLooper() == null) { new Handler(Looper.getMainLooper()).post(() -> toastLong(context, msg));
Looper.prepare();
}
toastLong(context, msg);
} }