package com.duben.microtribe.ui.widgets

import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.duben.microtribe.R
import com.duben.microtribe.common.AppConfig
import com.duben.microtribe.mvp.model.VipBean

class PhoneDialog(
    private val context: Context,
    private val listener: DialogListener
) : Dialog(
    context, R.style.dialog
) {
    private val lp: WindowManager.LayoutParams
    private val iv_phone_dialog_quit: ImageView
    private val tv_phone_dialog_phone: TextView
    private val tv_phone_dialog_phone2: TextView

    init {
        setContentView(R.layout.dialog_phone)
        // 设置window属性
        lp = window!!.attributes
        lp.gravity = Gravity.BOTTOM
        lp.width = WindowManager.LayoutParams.MATCH_PARENT
        lp.windowAnimations = R.style.DialogAnimBottom
        window!!.attributes = lp

        // 设置外部不可关闭
        setCancelable(false)
        setCanceledOnTouchOutside(false)
        setOnKeyListener { dialogInterface, i, keyEvent ->
            if (i == KeyEvent.KEYCODE_BACK) {
                true
            } else false
        }


        // 查找View
        iv_phone_dialog_quit = findViewById<View>(R.id.iv_phone_dialog_quit) as ImageView
        tv_phone_dialog_phone = findViewById<View>(R.id.tv_phone_dialog_phone) as TextView
        tv_phone_dialog_phone2 = findViewById<View>(R.id.tv_phone_dialog_phone2) as TextView
        iv_phone_dialog_quit.setOnClickListener(listener)
        tv_phone_dialog_phone.setOnClickListener(listener)
        tv_phone_dialog_phone2.setOnClickListener(listener)



//        val intent = Intent(Intent.ACTION_DIAL)
//        intent.data = Uri.parse("tel:" + "4000969950")
//        context.startActivity(intent)
    }

}