package com.ym.modulecommon.base

import com.ym.admodule.R
import com.ym.admodule.config.AdCache
import com.ym.admodule.config.AdManager
import com.ym.admodule.config.AdManager.loadNextCacheFullVideoAd
import com.ym.admodule.listener.ZXADSplashListener
import com.ym.modulecommon.utils.AdEventUtils
import kotlinx.android.synthetic.main.splash_resume.*

/**
 * Created by erwin on 2020/11/18
 */
class SplashResumeActivity : BaseActivity() {

    override fun layoutID(): Int = R.layout.splash_resume

    override fun before() {
        super.before()
    }

    override fun init() {
        AdManager.showSplashAd(this,"splash","",tv_skipview,splash_container,object :
            ZXADSplashListener {
            override fun onAdShow() {

            }

            override fun onAdSkip() {
                finish()
            }

            override fun onError(errorMsg: String?) {
                finish()
            }
        })
    }

    override fun finish() {
        if(AdCache.cacheAdMap.isEmpty() && AdCache.cacheAdMapB.isEmpty() || AdManager.checkTimeOut(
                AdEventUtils.AD_MODEL_REWARD
            )
        ){
            AdManager.isLoadReward = false
            AdManager.loadNextCacheRewardVideoAd("video",this)//反转加载一次
            AdManager.loadNextCacheFullVideoAd("fullvideo", this)

        }
        super.finish()
    }

}