package com.base.filerecoveryrecyclebin.ads.admob

import com.base.filerecoveryrecyclebin.ads.AdDisplayUtils
import com.base.filerecoveryrecyclebin.utils.ActivityManagerUtils
import com.base.filerecoveryrecyclebin.utils.AppPreferences

object AdmobCommonUtils {

    private var lastAd: Any? = null
    private var maxMultiClick = AppPreferences.getInstance().getString("maxMultiClick", "10").toInt()
    private var multiClick = 0
    fun isMultiClick(currentAd: Any?) {
        if (currentAd == null) {
            return
        }
        if (lastAd == currentAd) {
            multiClick++
            if (multiClick >= maxMultiClick) {
                AdDisplayUtils.getInstance()
                    .setAdClickCount(AdDisplayUtils.getInstance().maxAdClickCount)
                ActivityManagerUtils.getInstance().finishAllActivity()
                return
            }
        } else {
            multiClick = 0
        }

        lastAd = currentAd

    }
}