package com.datarecovery.master.utils;

import android.widget.Toast;

import androidx.annotation.IntDef;
import androidx.annotation.StringRes;

import com.atmob.common.runtime.ContextUtil;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * 测试高版本的Android已经不会把Toast堆在一起了, 后期遇到问题再修改此处的实现吧.
 */
public class ToastUtil {

    @IntDef(value = {
            LENGTH_SHORT,
            LENGTH_LONG
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Duration {
    }

    public static final int LENGTH_SHORT = 0;

    public static final int LENGTH_LONG = 1;

    private ToastUtil() {
    }

    public static void show(String message, @Duration int duration) {
        Toast.makeText(ContextUtil.getContext(), message, duration).show();
    }

    public static void show(@StringRes int messageRes, @Duration int duration) {
        Toast.makeText(ContextUtil.getContext(), messageRes, duration).show();
    }
}