Commit e2d3b641 authored by wanglei's avatar wanglei

[迭代]原生广告限制

parent 2aadf2c5
......@@ -196,7 +196,7 @@ class MyApplication : Application() {
private var lastTimePause = 0L
private var lastTimeResume = 0L
private fun isHotLaunch(): Boolean {
if ((lastTimeResume - lastTimePause) > 5000) {
if ((lastTimeResume - lastTimePause) > 3500) {
return true
}
return false
......
......@@ -152,6 +152,7 @@ abstract class BaseActivity<VB : ViewBinding>(
// intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
startActivity(intent)
finish()
}
var dialog: Dialog? = null
......
......@@ -101,7 +101,6 @@ class AdInterMgr {
val admobEvent = (adEvent as AdmobEvent)
val tag = adEvent.TAG
LogEx.logDebug(tag, "inter showReadyAd ac=${ac.javaClass.simpleName} currentAd=${adState.currentAd}")
if (ac.isFinishing || ac.isDestroyed || adState.currentAd == null) {
LogEx.logDebug(tag, "inter showReadyAd ac=null isFinishing isDestroyed")
showCallBack?.failed()
......
......@@ -40,7 +40,7 @@ class AdNativeMgr {
) {
admobEvent.adPulStart()
if (!LimitUtils.isAdShow(AdsType.NATIVE, admobEvent)) {
if (!LimitUtils.isAdShow(NATIVE, admobEvent)) {
return
}
......@@ -90,43 +90,42 @@ class AdNativeMgr {
nativeCallBack: ((Any?) -> Unit)? = null
) {
admobEvent.adPrepareShow()
if (!LimitUtils.isAdShow(NATIVE, admobEvent) || !LimitUtils.isShowNative(NATIVE, admobEvent)) {
cacheItems.clear()
return
}
Log.e(admobEvent.TAG, "native can show")
admobEvent.adPrepareShow()
if (!adAvailable()) {
//缓存过期了就清空
Log.e(admobEvent.TAG, "native cacheItems clear")
cacheItems.clear()
}
parent.isAdShowed = true
val nativeAd = cacheItems.peek()
if (nativeAd == null) {
loadAd(parent.context, admobEvent) { ad ->
Log.e(admobEvent.TAG, "native load show")
var showAction: (ad: NativeAd) -> Unit = { ad ->
parent.isAdShowed = true
nativeCallBack?.invoke(ad)
parent.setNativeAd(ad, layout)
admobEvent.showAd(ad.responseInfo)
//添加原生数量
LimitUtils.addNativeDisplayNum()
loadAd(MyApplication.appContext, AdmobEvent("nativeAd", "preload"), null)
}
} else {
if (nativeAd == null) {
loadAd(parent.context, admobEvent) { ad ->
Log.e(TAG, "load show")
showAction.invoke(ad)
}
} else {
val flag = cacheItems.remove(nativeAd)
Log.e(admobEvent.TAG, "native ready show remove=$flag size=${cacheItems.size}")
nativeCallBack?.invoke(nativeAd)
parent.setNativeAd(nativeAd, layout)
admobEvent.showAd(nativeAd.responseInfo)
loadAd(MyApplication.appContext, AdmobEvent("nativeAd", "preload"), null)
Log.e(TAG, "ready show remove=$flag size=${cacheItems.size}")
showAction.invoke(nativeAd)
}
}
......
......@@ -42,7 +42,7 @@ class AdOpenMgr {
adState.currentAdEvent?.let { adEvent.reqId = it.reqId }
if (!adEvent.isUnLimit) {
if (!LimitUtils.isAdShow(AdsType.OPEN, adEvent)) {
if (!LimitUtils.isAdShow(OPEN, adEvent)) {
showCallBack?.failed()
return
}
......@@ -103,6 +103,8 @@ class AdOpenMgr {
LimitUtils.addDisplayNum()
admobEvent.showAd(this@run.responseInfo, ac)
}
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
......
......@@ -16,6 +16,7 @@ object InstallHelps {
private val TAG = "InstallHelps"
//服务器上报的参数
var installReferrer = ""
get() {
return AppPreferences.getInstance().getString("install_referrer", field)
......
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