fixed Toast message not appearing when diplaying them from async context
This commit is contained in:
parent
b88957ff5f
commit
2c77c5aa96
1 changed files with 4 additions and 12 deletions
|
|
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue