package com.yidianling.consultant.dialog


import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager
import com.yidianling.consultant.R
import kotlinx.android.synthetic.main.consultant_expert_consult_assistant_popup_window.*

/**
 * 咨询助理浮层
 * Created by xj on 2019/10/30.
 */

class ConsultAssistantDialog(context: Context, val consultAssistantClickListener: OnConsultAssistantClickListener?) : Dialog(context, R.style.consultant_expert_dialog_default_style) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.consultant_expert_consult_assistant_popup_window)

        val params = window.attributes
        params.width = WindowManager.LayoutParams.WRAP_CONTENT
        params.height = WindowManager.LayoutParams.WRAP_CONTENT
        params.gravity = Gravity.RIGHT + Gravity.BOTTOM
        params.verticalMargin = 0.07f
        params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE //不拦截外部点击事件
        window.attributes = params
        window.setDimAmount(0f)

        window.setWindowAnimations(R.style.consultant_expert_consult_assistant_dialog_animate)

        consult_assistant.setOnClickListener {
            consultAssistantClickListener?.onClickAction()
        }

        setCanceledOnTouchOutside(false)
    }

    interface OnConsultAssistantClickListener {
        fun onClickAction() //隐私设置
    }
}