List of usage examples for android.os Handler post
public final boolean post(Runnable r)
From source file:com.senechaux.rutino.utils.NetworkUtilities.java
/** * Sends the authentication response from server back to the caller main UI thread through its handler. * // www .j ava 2 s. c o m * @param result * The boolean holding authentication result * @param handler * The main UI thread's handler instance. * @param context * The caller Activity's context. */ private static void sendResult(final Boolean result, final Handler handler, final Context context, final String response) { if (handler == null || context == null) { return; } handler.post(new Runnable() { public void run() { ((AuthenticatorActivity) context).onAuthenticationResult(result, response); } }); }
From source file:github.daneren2005.dsub.util.Notifications.java
public static void hidePlayingNotification(final Context context, final DownloadService downloadService, Handler handler) { playShowing = false;/*w w w .j av a 2s. c o m*/ // Remove notification and remove the service from the foreground handler.post(new Runnable() { @Override public void run() { downloadService.stopForeground(true); if (persistentPlayingShowing) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID_PLAYING); persistentPlayingShowing = false; } } }); // Get downloadNotification in foreground if playing if (downloadShowing) { showDownloadingNotification(context, downloadService, handler, downloadService.getCurrentDownloading(), downloadService.getBackgroundDownloads().size()); } // Update widget DSubWidgetProvider.notifyInstances(context, downloadService, false); }
From source file:com.nbos.phonebook.sync.client.Net.java
private static void sendValidationResult(final Boolean result, final String message, final Handler handler, final Context context) { Log.i(tag, "sendValidationResult(" + result + ")"); if (handler == null || context == null) { return;// w w w .j a va 2 s .c om } handler.post(new Runnable() { public void run() { ((ValidationActivity) context).onValidationResult(result, message); } }); }
From source file:com.nbos.phonebook.sync.client.Net.java
/** * Sends the authentication response from server back to the caller main UI * thread through its handler./*w ww . j ava 2s . c o m*/ * * @param result The boolean holding authentication result * @param handler The main UI thread's handler instance. * @param context The caller Activity's context. */ private static void sendResult(final Boolean result, final Handler handler, final Context context, final String message) { Log.i(tag, "sendResult(" + result + ")"); if (handler == null || context == null) { return; } handler.post(new Runnable() { public void run() { ((AuthenticatorActivity) context).onAuthenticationResult(result, message); } }); }
From source file:org.ttrssreader.utils.Utils.java
/** * Allos to send a toast from a background thread * * @param context the context, eg. MyApplication.context() * @param message like Toast.makeText(...) * @param length like Toast.makeText(...) *//*from ww w . ja v a 2 s . c o m*/ public static void showBackgroundToast(final Context context, final String message, final int length) { Handler handler = new Handler(context.getMainLooper()); handler.post(new Runnable() { @Override public void run() { Toast.makeText(context, message, length).show(); } }); }
From source file:eu.power_switch.gui.StatusMessageHandler.java
/** * Show Status Toast above all other views * * @param context any suitable context// w w w .j ava2s .co m * @param message toast message * @param duration duration of toast */ private static void showInfoToast(final Context context, final String message, final int duration) { Log.d("Status Toast: " + message); Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { // cancel last toast if (lastToast != null) { lastToast.cancel(); } // create and show new toast Toast toast = Toast.makeText(context.getApplicationContext(), message, duration); toast.show(); // save toast reference lastToast = toast; } }); }
From source file:eu.power_switch.gui.StatusMessageHandler.java
/** * Show Error Toast above all other views * * @param context any suitable context//from ww w .j av a 2 s . c om * @param e throwable */ private static void showErrorToast(final Context context, final Throwable e) { Log.e("Error Toast: ", e); Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { // cancel last toast if (lastToast != null) { lastToast.cancel(); } // create and show new toast Toast toast = Toast.makeText(context.getApplicationContext(), e.getClass().toString(), Toast.LENGTH_LONG); toast.show(); // save toast reference lastToast = toast; } }); }
From source file:org.schabi.newpipe.ErrorActivity.java
public static void reportError(Handler handler, final Context context, final List<Exception> el, final Class returnAcitivty, final View rootView, final ErrorInfo errorInfo) { handler.post(new Runnable() { @Override/*from w w w .j av a2s . c om*/ public void run() { reportError(context, el, returnAcitivty, rootView, errorInfo); } }); }
From source file:net.sourceforge.kalimbaradio.androidapp.util.NotificationUtil.java
private static void updateSimpleNotification(Context context, final DownloadServiceImpl downloadService, Handler handler, MusicDirectory.Entry song, boolean playing) { if (song == null || !playing) { hideNotification(downloadService, handler); } else {//from ww w . java2 s . c o m final Notification notification = createSimpleNotification(context, song); // Send the notification and put the service in the foreground. handler.post(new Runnable() { @Override public void run() { downloadService.startForeground(Constants.NOTIFICATION_ID_PLAYING, notification); } }); } }
From source file:net.sourceforge.kalimbaradio.androidapp.util.NotificationUtil.java
private static void updateCustomNotification(Context context, final DownloadServiceImpl downloadService, Handler handler, MusicDirectory.Entry song, boolean playing) { if (song == null) { hideNotification(downloadService, handler); } else if (!isNotificationHiddenByUser(context)) { final Notification notification = createCustomNotification(context, song, playing); // Send the notification and put the service in the foreground. handler.post(new Runnable() { @Override/*from w w w . j a v a 2 s . c om*/ public void run() { downloadService.startForeground(Constants.NOTIFICATION_ID_PLAYING, notification); } }); } }