Log the toast message immediately, not delayed in the main thread

(this helps understanding logs)
here
cpfeiffer 2016-02-24 23:53:30 +01:00
parent 8de836efb8
commit defa97b882
1 changed files with 1 additions and 2 deletions

View File

@ -202,18 +202,17 @@ public class GB {
* @param ex optional exception to be logged * @param ex optional exception to be logged
*/ */
public static void toast(final Context context, final String message, final int displayTime, final int severity, final Throwable ex) { public static void toast(final Context context, final String message, final int displayTime, final int severity, final Throwable ex) {
log(message, severity, ex); // log immediately, not delayed
if (env().isLocalTest()) { if (env().isLocalTest()) {
return; return;
} }
Looper mainLooper = Looper.getMainLooper(); Looper mainLooper = Looper.getMainLooper();
if (Thread.currentThread() == mainLooper.getThread()) { if (Thread.currentThread() == mainLooper.getThread()) {
log(message, severity, ex);
Toast.makeText(context, message, displayTime).show(); Toast.makeText(context, message, displayTime).show();
} else { } else {
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {
log(message, severity, ex);
Toast.makeText(context, message, displayTime).show(); Toast.makeText(context, message, displayTime).show();
} }
}; };