package com.gamedog.vididin.main

import android.app.Activity
import com.ama.core.architecture.util.AndroidUtil
import com.ama.core.architecture.util.setOnClickBatch
import com.ama.core.architecture.widget.BindingDialog
import com.gamedog.vididin.databinding.DialogWatchVideoBinding
import com.gamedog.vididin.router.Router


class WatchVideoDialog(context: Activity) : BindingDialog<DialogWatchVideoBinding>(context, DialogWatchVideoBinding::inflate) {

    init {
        build()
    }


    private fun build() {
        with()
        setCenter()
        setMaskValue(0.93f)
        setCanCancel(false)

        mBinding.run {
            setOnClickBatch(flAction, ivClose) {
                when (this) {
                    ivClose ->  {
                        dismiss()
                    }
                    flAction ->  {
                        gotoWatchVideo()
                    }
                }
            }
        }
    }

    private fun gotoWatchVideo() {
        val taskUUID = AndroidUtil.genRandomInt(500000, Int.MAX_VALUE)
        registerEvents({
            AndroidUtil.showToast("广告任务完成")
            dismiss()
        }, taskUUID)

        Router.WatchAd.startActivity(mActivity, taskUUID)
    }



}

