AxbConfirmDialog.kt 1.64 KB
Newer Older
洪国微 committed
1 2 3 4 5 6 7
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
8
import kotlinx.android.synthetic.main.audioim_dialog_axb_confirm.*
洪国微 committed
9 10 11 12 13 14 15 16 17 18 19

/**
 * @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
20
    private var type :Int = 1 //弹窗类型,1为手动切换axb布局,2为自动切换axb布局
洪国微 committed
21

22
    constructor(activity: Activity?,type:Int, listener: OnClickEnsureListener?) : super(activity) {
洪国微 committed
23 24
        this.activity = activity
        this.listener = listener
25
        this.type = type
洪国微 committed
26 27 28 29
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
30
        if (this.type==2){
洪国微 committed
31
            setContentView(R.layout.audioim_dialog_autoaxb_confirm)
32
        }else{
洪国微 committed
33
            setContentView(R.layout.audioim_dialog_axb_confirm)
34 35
        }

洪国微 committed
36
        setCanceledOnTouchOutside(false)
37
        setCancelable(false)
洪国微 committed
38 39
        window.setBackgroundDrawable(ColorDrawable())
        ic_close.setOnClickListener {
40
            listener?.onClose()
洪国微 committed
41 42 43 44
            dismiss()
        }

        rl_ensure.setOnClickListener {
45
            listener?.onClickEnsure()
洪国微 committed
46 47 48 49 50 51
            dismiss()
        }
    }

    interface OnClickEnsureListener {
        fun onClickEnsure()
52
        fun onClose()
洪国微 committed
53 54 55 56 57 58 59 60 61
    }

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