package cn.ninegame.ad.demo.util;

import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;

/**
 * <p>Description: </p>
 * <br>
 * Copyright: Copyright (c) 2024
 *
 * @author tangxiyong.txy@alibaba-inc.com
 * @version 1.0
 * @date 2024/6/14 14:05
 */
public class ToastUtil {

    public static void show(Activity activity, String msg) {
        activity.runOnUiThread(() -> Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show());
    }

    public static void show(Context context, String msg) {
        Handler handler = new Handler(Looper.getMainLooper());
        handler.post(() -> Toast.makeText(context, msg, Toast.LENGTH_LONG).show());
    }

}
