List of usage examples for android.app Activity runOnUiThread
public final void runOnUiThread(Runnable action)
From source file:com.ap.github.utils.ToastUtils.java
public static void showToastOnSubThread(@NonNull Activity activity, @NonNull String content) { activity.runOnUiThread(() -> Toast.makeText(activity.getBaseContext(), content, Toast.LENGTH_SHORT).show()); }
From source file:com.ap.github.utils.ToastUtils.java
public static void showToastOnSubThread(@NonNull Activity activity, @StringRes int stringResId) { activity.runOnUiThread( () -> Toast.makeText(activity.getBaseContext(), stringResId, Toast.LENGTH_SHORT).show()); }
From source file:Main.java
public static void toast(final String text) { Activity a = activity.get(); if (a == null) { return;/*w w w .j a va 2s. co m*/ } a.runOnUiThread(new Runnable() { public void run() { Toast.makeText(context, text, Toast.LENGTH_LONG).show(); } }); }
From source file:com.jonbanjo.cupsprint.Util.java
public static void showToast(final Activity activity, final String toast) { activity.runOnUiThread(new Runnable() { public void run() { Toast.makeText(activity, toast, Toast.LENGTH_LONG).show(); }//from w w w . j a v a2 s. c o m }); }
From source file:Main.java
/** * A method to create a toast message on any screen. * * @param activity : screen on which the toast message should be shown. * @param msg : the message to be shown. *///from ww w . java2s.c o m public static void createToastMessage(final Activity activity, final String msg) { if (!isNullOrEmpty(msg)) activity.runOnUiThread(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(activity.getApplicationContext(), msg, Toast.LENGTH_SHORT); toast.show(); } }); }
From source file:Main.java
private static void waitForFragmentTransaction(final Activity activity) throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); activity.runOnUiThread(new Runnable() { @Override// w w w .j av a2 s. c o m public void run() { activity.getFragmentManager().executePendingTransactions(); latch.countDown(); } }); latch.await(); }
From source file:Main.java
private static void post(@Nullable Activity target, @NonNull Runnable runnable) { if (target == null || target.isFinishing()) return;//from ww w .j a va 2 s . co m target.runOnUiThread(runnable); }
From source file:Main.java
private static void post(@Nullable Activity target, @NonNull Runnable runnable) { if (target == null || target.isFinishing()) { return;/*www.ja va 2 s . c o m*/ } target.runOnUiThread(runnable); }
From source file:Main.java
/** * Shows an error alert dialog with the given message. * //from www . j a v a 2 s . c o m * @param activity * activity * @param message * message to show or {@code null} for none */ public static void showError(final Activity activity, String message) { final String errorMessage = message == null ? "Error" : "[Error ] " + message; activity.runOnUiThread(new Runnable() { public void run() { Toast.makeText(activity, errorMessage, Toast.LENGTH_LONG).show(); } }); }
From source file:Main.java
/** * Shows an error alert dialog with the given message. * // w w w . j a va 2 s .co m * @param activity activity * @param message message to show or {@code null} for none */ public static void showError(final Activity activity, String message) { final String errorMessage = message == null ? "Error" : "[Error ] " + message; activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, errorMessage, Toast.LENGTH_LONG).show(); } }); }