package com.base.filerecoveryrecyclebin.view

import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.View
import android.widget.TextView

class CustomDialog(context: Context, layoutId: Int? = null, view: View? = null) : Dialog(context) {
    private var countdownText: TextView? = null

    init {
        layoutId?.let { setContentView(it) }
        view?.let { setContentView(it) }
        val window = window
        window?.apply {
            setGravity(Gravity.CENTER)
            setBackgroundDrawableResource(android.R.color.transparent)
        }
        setCancelable(false)
    }

    fun setButtonClickListener(viewId: Int, listener: () -> Unit) {
        val button = findViewById<View>(viewId) as? TextView
        button?.setOnClickListener {
            listener.invoke()
        }
    }

    fun setCountdownText(viewId: Int) {
        countdownText = findViewById(viewId)
    }

    fun updateCountdownText(seconds: String) {
        countdownText?.text = seconds
    }
}

