Commit e2d3b641 authored by wanglei's avatar wanglei

[迭代]原生广告限制

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