package com.hxsmart.intelligentizepos.util;
import android.content.Context;
import android.os.Looper;
import android.view.Gravity;
import android.widget.Toast;
import com.hxsmart.intelligentizepos.application.IntelligentizeApplication;
/**
* Toast Util Class
* Created by llbt on 2016/3/31.
*/
public class ToastUtil {
public static void show(Object toastText) {
Toast toast = Toast.makeText(IntelligentizeApplication.getInstance(), toastText != null?toastText.toString():"", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
//常规Toast
public static void toast(Context mContext, String str) {
try {
Toast toast = Toast.makeText(mContext, str, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
} catch (Exception e) {
e.printStackTrace();
}
}
//子线程Toast
public static void toastThread(Context mContext, String str) {
try {
Looper.prepare();
Toast toast = Toast.makeText(mContext, str, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
Looper.loop();
} catch (Exception e) {
e.printStackTrace();
}
}
}