package com.dayu.qiheonlinelibrary.utils; 
 | 
  
 | 
import android.content.Context; 
 | 
import android.os.Handler; 
 | 
import android.os.Looper; 
 | 
import android.text.TextUtils; 
 | 
import android.widget.Toast; 
 | 
  
 | 
/** 
 | 
 * Toast工具类 
 | 
 */ 
 | 
public class ToastUtil { 
 | 
  
 | 
  
 | 
    public static void showToastLongOnMainLooper(final Context context, final String message) { 
 | 
        new Handler(Looper.getMainLooper()).post(new Runnable() { 
 | 
            @Override 
 | 
            public void run() { 
 | 
                Toast.makeText(context, message, Toast.LENGTH_LONG).show(); 
 | 
            } 
 | 
        }); 
 | 
    } 
 | 
  
 | 
    private static Toast makeText(Context context, CharSequence text, int duration) { 
 | 
        return Toast.makeText(context, text, duration); 
 | 
    } 
 | 
  
 | 
    public static void showToastShort(Context context, String s) { 
 | 
        if (s != null) { 
 | 
            if (!TextUtils.isEmpty(s)) 
 | 
                makeText(context, s, Toast.LENGTH_SHORT).show(); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public static void showToastLong(Context context, String s) { 
 | 
        if (!TextUtils.isEmpty(s)) { 
 | 
            makeText(context, s, Toast.LENGTH_LONG).show(); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public static void showToast(Context context, String s) { 
 | 
        if (s != null) { 
 | 
            makeText(context, s, Toast.LENGTH_LONG).show(); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public static void showToast(Context context, int resId) { 
 | 
        showToastLong(context, context.getString(resId)); 
 | 
    } 
 | 
  
 | 
    public static void showToastShort(Context context, int resId) { 
 | 
        showToastShort(context, context.getString(resId)); 
 | 
    } 
 | 
  
 | 
    public static void showToastLong(Context context, int resId) { 
 | 
        showToastLong(context, context.getString(resId)); 
 | 
    } 
 | 
  
 | 
  
 | 
} 
 |