Commit f4988def authored by wanglei's avatar wanglei

[优化]测试

parent 3bb99921
......@@ -5,7 +5,6 @@ import com.dumpster.cleaner.business.ads.AdsType.Companion.INSERT
import com.dumpster.cleaner.business.ads.AdsType.Companion.OPEN
import com.dumpster.cleaner.business.ads.LimitUtils.interLastShowTime
import com.dumpster.cleaner.business.ads.LimitUtils.openLastShowTime
import com.dumpster.cleaner.utils.LogEx
class AdState<T>() {
......@@ -94,8 +93,7 @@ class AdState<T>() {
}
fun adAvailable() =
currentAd != null || ((System.currentTimeMillis() - lastLoadTime) / 1000 / 60).toInt() < 30
fun needLoad() = currentAd == null || ((System.currentTimeMillis() - lastLoadTime) / 1000 / 60).toInt() > 30
}
......@@ -243,7 +243,7 @@ object AdsMgr {
@LayoutRes layout: Int,
nativeCallBack: ((Any?) -> Unit)? = null
) {
if (!adsConfigBean.isAdShow) {
if (!adsConfigBean.isAdShow || !LimitUtils.isShowNative(AdsType.NATIVE, null)) {
nativeView.visibility = View.GONE
nativeCallBack?.invoke(null)
return
......
......@@ -5,6 +5,7 @@ import com.dumpster.cleaner.BuildConfig
import com.dumpster.cleaner.bean.config.AdConfigBean
import com.dumpster.cleaner.utils.AppPreferences
import com.dumpster.cleaner.utils.KotlinExt.toFormatTime4
import com.dumpster.cleaner.utils.LogEx
/**
......@@ -155,8 +156,10 @@ object LimitUtils {
* 开屏限制
*/
fun isIntervalOpenLimit(adEvent: AdEvent): Boolean {
val flag = ((System.currentTimeMillis() - openLastShowTime) / 1000).toInt() < (AdConfigBean.adsConfigBean.timeIntervalOpen)
Log.e(adEvent.TAG, "open isIntervalOpenLimit=$flag")
val passTime = ((System.currentTimeMillis() - openLastShowTime) / 1000).toInt()
val interval = AdConfigBean.adsConfigBean.timeIntervalOpen
val flag = passTime < interval
Log.e(adEvent.TAG, "open isIntervalOpenLimit=$flag passTime=$passTime interval=$interval")
if (flag) {
adEvent.adShowError("ad in timeInterval")
}
......@@ -169,7 +172,7 @@ object LimitUtils {
fun isIntervalInterLimit(adEvent: AdEvent): Boolean {
val passTime = ((System.currentTimeMillis() - interLastShowTime) / 1000).toInt()
val interval = AdConfigBean.adsConfigBean.timeInterval
val flag = passTime < (interval)
val flag = passTime < interval
Log.e(
adEvent.TAG,
"inter isIntervalInterLimit=$flag interLastShowTime=$interLastShowTime passTime=$passTime interval=$interval"
......@@ -219,10 +222,16 @@ object LimitUtils {
AppPreferences.getInstance().put(NUM_NATIVE_DISPLAY, 0)
}
val flag = isNativeLimited
val todayNumber = AppPreferences.getInstance().getInt(NUM_NATIVE_DISPLAY, 0)
val max = AdConfigBean.adsConfigBean.numNativeDisplayLimit
LogEx.logDebug(adEvent?.TAG ?: "", "native todayNumber=$todayNumber max=$max ")
if (flag) {
val value = "current${getAdEventMsg(adsType)} " +
"show=${AppPreferences.getInstance().getInt(NUM_NATIVE_DISPLAY, 0)} " +
"${getAdEventMsg(adsType).lowercase()}_" + "max_show=${AdConfigBean.adsConfigBean.numNativeDisplayLimit}"
"show=${todayNumber} " +
"${getAdEventMsg(adsType).lowercase()}_" + "max_show=${max}"
adEvent?.adLimited(value)
}
return !flag
......
......@@ -12,7 +12,6 @@ import com.dumpster.cleaner.business.ads.AdState
import com.dumpster.cleaner.business.ads.AdsShowCallBack
import com.dumpster.cleaner.business.ads.AdsType
import com.dumpster.cleaner.business.ads.AdsType.Companion.INSERT
import com.dumpster.cleaner.business.ads.AdsType.Companion.OPEN
import com.dumpster.cleaner.business.ads.LimitUtils
import com.dumpster.cleaner.business.ads.admob.AdmobEvent.AdmobOnPaidEventListener
import com.dumpster.cleaner.utils.LogEx
......@@ -61,7 +60,7 @@ class AdInterMgr {
}
val needLoad = !adState.adAvailable()
val needLoad = adState.needLoad()
this.showCallBack = showCallBack
if (adState.adDialog == null) {
......@@ -103,9 +102,9 @@ class AdInterMgr {
val admobEvent = (adEvent as AdmobEvent)
val tag = adEvent.TAG
LogEx.logDebug(tag, "showReadyAd ac=${ac.javaClass.simpleName} currentAd=${adState.currentAd}")
LogEx.logDebug(tag, "inter showReadyAd ac=${ac.javaClass.simpleName} currentAd=${adState.currentAd}")
if (ac.isFinishing || ac.isDestroyed || adState.currentAd == null) {
LogEx.logDebug(tag, "showReadyAd ac=null isFinishing isDestroyed")
LogEx.logDebug(tag, "inter showReadyAd ac=null isFinishing isDestroyed")
showCallBack?.failed()
adState.onAdDisplayFailed()
return
......
......@@ -8,7 +8,6 @@ import com.dumpster.cleaner.business.ads.AdEvent
import com.dumpster.cleaner.business.ads.AdState
import com.dumpster.cleaner.business.ads.AdsShowCallBack
import com.dumpster.cleaner.business.ads.AdsType
import com.dumpster.cleaner.business.ads.AdsType.Companion.INSERT
import com.dumpster.cleaner.business.ads.AdsType.Companion.OPEN
import com.dumpster.cleaner.business.ads.LimitUtils
import com.dumpster.cleaner.business.ads.admob.AdmobEvent.AdmobOnPaidEventListener
......@@ -53,7 +52,7 @@ class AdOpenMgr {
}
}
val needLoad = !adState.adAvailable()
val needLoad = adState.needLoad()
this.showCallBack = showCallBack
adEvent.adPrepareShow()
......@@ -88,7 +87,7 @@ class AdOpenMgr {
val admobEvent = (adEvent as AdmobEvent)
if (ac.isFinishing || ac.isDestroyed || adState.currentAd == null) {
LogEx.logDebug(TAG, "showReadyAd ac=null isFinishing isDestroyed")
LogEx.logDebug(adEvent.TAG, "open showReadyAd ac=null isFinishing isDestroyed")
return
}
......
......@@ -191,11 +191,10 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(ActivitySplashBinding
// binding.progressBar.setProgress(100.0)
binding.root.postDelayed({ jumpNext() }, 250)
}
LogEx.logDebug("AdmobEvent", "inter adShowed=${adShowed}")
LogEx.logDebug("AdmobEvent", "open adShowed=${adShowed} inter")
if (adShowed) {
action.invoke()
} else {
LogEx.logDebug("AdmobEvent", "inter open show inter")
AdsMgr.showInsert(this@SplashActivity, showCallBack = object : AdsShowCallBack() {
override fun next() {
action.invoke()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment