package com.ydl.audioim.widget

import android.app.Activity
import android.app.Dialog
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import com.ydl.audioim.R
import kotlinx.android.synthetic.main.audioim_dialog_axb_confirm.*

/**
 * @author jiucheng
 * @描述:Axb呼叫确认弹窗
 * @Copyright Copyright (c) 2018
 * @Company 壹点灵
 * @date 2018/12/27
 */
class AxbConfirmDialog : Dialog {
    private var activity: Activity? = null
    private var listener: OnClickEnsureListener? = null

    constructor(activity: Activity?, listener: OnClickEnsureListener?) : super(activity) {
        this.activity = activity
        this.listener = listener
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.audioim_dialog_axb_confirm)
        setCanceledOnTouchOutside(false)
        window.setBackgroundDrawable(ColorDrawable())
        ic_close.setOnClickListener {
            dismiss()
        }

        rl_ensure.setOnClickListener {
            if (listener != null) {
                listener!!.onClickEnsure()
            }
            dismiss()
        }
    }

    interface OnClickEnsureListener {
        fun onClickEnsure()
    }

    override fun show() {
        if (null == activity || activity!!.isFinishing) {
            return
        }
        super.show()
    }
}