package com.base.locationsharewhite.ads

import com.base.locationsharewhite.utils.AppPreferences

/**
 * 广告限制配置
 *
 * @property isInBlackList 是否在黑名单
 * @property numDisplayLimit  展示次数限制 -1为不限制，0为彻底关闭显示
 * @property numRequestLimit  请求次数限制 -1为不限制，0为彻底关闭显示
 * @property numClickLimit  点击次数限制 -1为不限制，0为彻底关闭显示
 * @property timeInterval  广告间隔时间
 */
data class AdsConfigBean(
    var isInBlackList: Boolean = false,
    var numDisplayLimit: Int = -1,
    var numRequestLimit: Int = -1,
    var numClickLimit: Int = -1,
    var timeInterval: Int = 1,
    var openAdLoading: Int = 15,
) {
    companion object {
        fun getSpConfigBean(): AdsConfigBean {
            val adsConfigBean = AdsConfigBean()
            adsConfigBean.apply {
                isInBlackList = AppPreferences.getInstance().getBoolean("isInBlackList", false)
                numDisplayLimit = AppPreferences.getInstance().getInt("numDisplayLimit", -1)
                numRequestLimit = AppPreferences.getInstance().getInt("numRequestLimit", -1)
                numClickLimit = AppPreferences.getInstance().getInt("numClickLimit", -1)
                timeInterval = AppPreferences.getInstance().getInt("timeInterval", 1)
                openAdLoading = AppPreferences.getInstance().getInt("openAdLoading", 15)
            }
            return adsConfigBean
        }
    }
}