package com.duben.microtribe.ui.widgets

import android.app.Dialog
import android.content.Context
import android.location.GnssAntennaInfo.Listener
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import com.duben.microtribe.R
import com.duben.microtribe.common.AppConfig
import com.duben.microtribe.mvp.model.VedioBean
import com.duben.microtribe.utils.SpanUtils
import com.duben.microtribe.utils.TimeRender
import java.util.*

class DetailAdDialog(private val context: Context, private val listener: DialogListener?) :
    Dialog(
        context, R.style.dialog
    ) {
    private val lp: WindowManager.LayoutParams
    private val iv_detail_ad_next: Button
    private val tv_detail_ad_unlocktext: TextView

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

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

        // 查找View
        iv_detail_ad_next = findViewById<View>(R.id.iv_detail_ad_next) as Button
        findViewById<View>(R.id.iv_detail_quit).setOnClickListener {
            dismiss()
        }
        tv_detail_ad_unlocktext = findViewById<View>(R.id.tv_detail_ad_unlocktext) as TextView

        tv_detail_ad_unlocktext.text = AppConfig.detailDialogUnlockText
        iv_detail_ad_next.setOnClickListener(listener)
    }
}