package com.grkj.iscs.view.dialog

import android.content.Context
import android.view.View
import android.view.View.GONE
import com.grkj.iscs.view.base.BaseDialog
import com.grkj.iscs.databinding.CommonDialogLoadingProgressBinding

class LoadingProgressDialog(context: Context) :
    BaseDialog<CommonDialogLoadingProgressBinding>(context) {

    override val viewBinding: CommonDialogLoadingProgressBinding
        get() = CommonDialogLoadingProgressBinding.inflate(layoutInflater)

    override fun initView() {
        setCanceledOnTouchOutside(false)
    }

    override fun show() {
        super.show()
        if (!mBinding!!.avlivCommon.isShown) mBinding!!.avlivCommon.smoothToShow()
    }

    override fun cancel() {
        super.cancel()
        try {
            mBinding?.avlivCommon?.smoothToHide()
        } catch (e: Exception) {
        }
    }

    fun setProgress(proStr: String?) {
        try {
            if (proStr.isNullOrEmpty()) {
                mBinding?.tvCommonProgress?.visibility = GONE
            } else {
                mBinding?.tvCommonProgress?.visibility = View.VISIBLE
                mBinding?.tvCommonProgress?.text = proStr
            }
        } catch (e: Exception) {
        }
    }
}