Android Open Source - android-util Toast Master






From Project

Back to project page android-util.

License

The source code is released under:

Apache License

If you think the Android project android-util listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ms.square.android.util;
//from   ww w. j a  v a2 s  . c  o  m
import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

/**
 * This class prevents multiple toasts from being queued.
 */
public final class ToastMaster {

    private static Toast sToast = null;

    private ToastMaster() {
    }

    public static void setToast(Toast toast) {
        if (sToast != null) {
            sToast.cancel();
        }
        sToast = toast;
    }

    public static void cancelToast() {
        if (sToast != null) {
            sToast.cancel();
        }
        sToast = null;
    }

    public static void showToast(Context context, String msg, int display_length) {
        Toast toast = Toast.makeText(context, msg, display_length);
        toast.setGravity(Gravity.BOTTOM, 0, 0);
        // displays in the bottom of the screen
        ToastMaster.setToast(toast);
        toast.show();
    }
}




Java Source Code List

com.ms.square.android.util.AnimUtil.java
com.ms.square.android.util.AppUtil.java
com.ms.square.android.util.CameraUtil.java
com.ms.square.android.util.FileUtil.java
com.ms.square.android.util.LogUtil.java
com.ms.square.android.util.NetUtil.java
com.ms.square.android.util.StreamUtil.java
com.ms.square.android.util.StringUtil.java
com.ms.square.android.util.ToastMaster.java
com.ms.square.android.util.UIUtil.java