ToastUtil.java 816 Bytes
package com.cnlive.gundam.video.utils;

import android.view.Gravity;
import android.widget.Toast;


import com.cnlive.gundam.application.CNLiveApplication;




public class ToastUtil {
    private static long back_pressed;
    private static String show_msg = "";

    public static void showToast(String str, int duration) {
        if (str.equals("")) return;
        if (back_pressed + 2000 < System.currentTimeMillis() || !show_msg.equals(str)) {
            show_msg = str;

            Toast toast = Toast.makeText(CNLiveApplication.getContext(), str, duration);

            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        }
        back_pressed = System.currentTimeMillis();
    }


    public static void showToast(String str) {
        showToast(str, Toast.LENGTH_SHORT);
    }
}