package rememberic

import android.app.Activity
import android.view.View
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatDialog
import com.easy.clean.R
import tooic.fatalityic.corroborateic.indexic.Lurkic
import autonomyic.polemicalic.congestionic.Unwindic
import com.easy.clean.databinding.DetouricBinding

class Hereditaryic(val activity: Activity) {

    val dialog = AppCompatDialog(activity)
    val binding = DetouricBinding.inflate(activity.layoutInflater)
    var clean: (() -> Unit)? = null
    var ad: (() -> Unit)? = null

    fun init() {
        dialog.setContentView(binding.root)
        dialog.setCanceledOnTouchOutside(true)
        val params = dialog.window?.attributes
        dialog.window?.attributes = params
        params?.width = LinearLayout.LayoutParams.MATCH_PARENT
        dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
        initView()
    }

    private fun initView() {
        binding.traditionalistic.setOnClickListener {
            dialog.dismiss()
        }
        binding.concussionic.setOnClickListener {
            dialog.dismiss()
            activity.finish()
        }
        binding.drinkeric.setOnClickListener {
            dialog.dismiss()
            clean?.invoke()
        }

    }

    fun show() {
        dialog.show()
        if (Lurkic.adsConfigBean.isAdShow) {
            Unwindic.showNative(binding.protectic, R.layout.sixtiethic)
        } else {
            binding.inconceivableic.visibility = View.GONE
        }
    }

    fun hide() {
        dialog.hide()
    }
}