1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 01:55:50 +01:00

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

(this helps understanding logs)
This commit is contained in:
cpfeiffer 2016-02-24 23:53:30 +01:00
parent 8de836efb8
commit defa97b882

View File

@ -202,18 +202,17 @@ public class GB {
* @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) {
log(message, severity, ex); // log immediately, not delayed
if (env().isLocalTest()) {
return;
}
Looper mainLooper = Looper.getMainLooper();
if (Thread.currentThread() == mainLooper.getThread()) {
log(message, severity, ex);
Toast.makeText(context, message, displayTime).show();
} else {
Runnable runnable = new Runnable() {
@Override
public void run() {
log(message, severity, ex);
Toast.makeText(context, message, displayTime).show();
}
};