package com.grkj.iscs_mc.util

import android.content.Context
import android.os.Looper
import android.widget.Toast
import com.grkj.iscs_mc.MyApplication
import com.grkj.iscs_mc.R

class ToastUtils private constructor(context: Context) : Toast(context) {

    companion object {

        fun tip(text: CharSequence?, duration: Int = LENGTH_SHORT) {
            if (Looper.myLooper() != Looper.getMainLooper()) {
                Executor.runOnMain {
                    tip(text)
                }
                return
            }
            makeText(MyApplication.instance!!, text, duration).show()
        }

        fun tip(text: Int, duration: Int = LENGTH_SHORT) =
            tip(MyApplication.instance?.applicationContext?.resources?.getString(text), duration)
    }
}