package com.base.appzxhy.drouterimp

import android.app.Activity
import com.base.appzxhy.ads.AdsMgr
import com.base.appzxhy.ads.AdsShowCallBack
import com.base.appzxhy.bean.config.AdConfigBean
import com.didi.drouter.annotation.Service
import com.koko.router.ad.InterAdService

@Service(function = [InterAdService::class])
class InterAdServiceImp : InterAdService {

    override fun showInterAd(activity: Activity, interWhere: String, callBack: () -> Unit) {

        val isUnLimit = false

        if (AdConfigBean.adsConfigBean.functionInShowAd) {
            AdsMgr.showInsert(activity, isUnLimit, object : AdsShowCallBack() {
                override fun close(where: Int) {
                    callBack.invoke()
                }

                override fun failed(where: Int) {
                    callBack.invoke()
                }

                override fun googleFailed(where: Int) {
                    callBack.invoke()
                }
            })
        } else {
            callBack.invoke()
        }

    }

    override fun showInterAdBack(activity: Activity, interWhere: String, callBack: () -> Unit) {
        val isUnLimit = false

        if (AdConfigBean.adsConfigBean.functionBackShowAd) {
            AdsMgr.showInsert(activity, isUnLimit, object : AdsShowCallBack() {
                override fun close(where: Int) {
                    callBack.invoke()
                }

                override fun failed(where: Int) {
                    callBack.invoke()
                }

                override fun googleFailed(where: Int) {
                    callBack.invoke()
                }
            })
        } else {
            callBack.invoke()
        }
    }

}