package change.me.util.library;

import android.app.Application;
import android.os.Handler;
import android.widget.Toast;

/**
 * Toast utils
 */
public final class Toasts {

    private static final String FUTURE_MESSAGE = "This functionality will be implemented in the near future";

    private static final Application app;

    static {
        app = Utils.getApp();
    }

    private Toasts() {
    }

    public static void showShort(int resId) {
        showShort(Res.getText(resId));
    }

    public static void showShort(CharSequence message) {
        show(message, Toast.LENGTH_SHORT);
    }

    public static void showLong(int resId) {
        showLong(Res.getText(resId));
    }

    public static void showLong(CharSequence message) {
        show(message, Toast.LENGTH_LONG);
    }

    public static void showShortFromBackground(int resId) {
        showShortFromBackground(Res.getText(resId));
    }

    public static void showShortFromBackground(CharSequence message) {
        showFromBackground(message, Toast.LENGTH_SHORT);
    }

    public static void showLongFromBackground(int resId) {
        showLongFromBackground(Res.getText(resId));
    }

    public static void showLongFromBackground(CharSequence message) {
        showFromBackground(message, Toast.LENGTH_LONG);
    }

    public static void showFuture() {
        show(FUTURE_MESSAGE, Toast.LENGTH_LONG);
    }

    private static void show(CharSequence text, int duration) {
        Toast.makeText(app, text, duration).show();
    }

    private static void showFromBackground(final CharSequence text, final int duration) {
        Handler handler = new Handler();
        handler.post(new Runnable() {
            @Override
            public void run() {
                show(text, duration);
            }
        });
    }

}

@@ -62,35 +62,8 @@
 on;%0A
-import android.os.Handler;%0A
 impo
@@ -1593,61 +1593,27 @@
     
-Handler handler = new Handler();%0A        handler.post
+Utils.runOnUiThread
 (new

Fix for show toast from background.