package com.sjkj.base_lib.utils;

import android.os.Handler;
import android.text.TextUtils;
import android.widget.Toast;

import com.sjkj.base_lib.app.AppManager;

public class ToastUtils {
    public static void show(String info) {
        try {
            if (!TextUtils.isEmpty(info) && info.contains("timeout")) {
                info = "网络请求超时，请检查网络";
            }
            String finalInfo = info;
            AppManager.getAppManager().currentActivity().runOnUiThread(new Runnable() {
                public void run() {
                    final Toast toast = Toast.makeText(AppManager.getAppManager().currentActivity(), finalInfo, Toast.LENGTH_LONG);
                    toast.show();
                    Handler handler = new Handler();
                    handler.postDelayed(new Runnable() {
                        public void run() {
                            toast.cancel();
                        }
                    }, 3000);
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
