package com.ym.library.utils

import android.content.Context
import android.text.Html
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import android.widget.Toast
import com.ym.library.R
import com.ym.modulecommon.AppliContext

/**
 * Created by erwin on 2020/11/5
 *
 */
object ToastUtils {


    /**
     * 弹出文字
     */
    fun showTextToast(s: String) {
        val context: Context = AppliContext.get()
        val view: View = LayoutInflater.from(context).inflate(R.layout.toast_text_layout, null)
        val title: TextView = view.findViewById(R.id.toast_tv) as TextView
        title.setText(s)
        showToast(context, view)
    }

    private fun showToast(context: Context, view: View) {
        val toast = Toast(context)
        toast.setGravity(Gravity.CENTER_HORIZONTAL or Gravity.CENTER, 0, 0)
        toast.setDuration(Toast.LENGTH_LONG)
        toast.setView(view)
        toast.show()
    }

}