Commit 60b29712 authored by wanglei's avatar wanglei

[pangle]pangle广告

parent 802e3204
......@@ -23,6 +23,7 @@ import com.base.appzxhy.bean.config.ConfigBean.Companion.configBean
//import com.base.appzxhy.business.ads.applovin.MaxNativeMgr
//import com.base.appzxhy.business.ads.applovin.MaxOpenMgr
import com.base.appzxhy.business.helper.EventUtils
import com.base.appzxhy.business.pangle.PangleInterMgr
import com.base.appzxhy.business.pangle.PangleOpenMgr
import com.base.appzxhy.utils.AppPreferences
import com.base.appzxhy.utils.LogEx
......@@ -68,6 +69,10 @@ object AdsMgr {
PangleOpenMgr()
}
private val pangleInterMgr by lazy {
PangleInterMgr()
}
/**
* 是否初始化
*/
......@@ -253,13 +258,14 @@ object AdsMgr {
// showCallBack?.failed()
// return
// }
LogEx.logDebug("showAd", "adSwitch=${adsConfigBean.adSwitch}")
val from = activity::class.java.simpleName
// LogEx.logDebug("showAd", "adSwitch=${adsConfigBean.adSwitch}")
// val from = activity::class.java.simpleName
// if (true) {
// adInterMgr.show(activity, AdmobEvent("interAd", from).apply { this.isUnLimit = isUnLimit }, showCallBack)
// } else {
// maxInsertMgr.show(activity, isUnLimit, AdMaxEvent("interAd", from), showCallBack)
// }
pangleInterMgr.show(activity, showCallBack)
}
/**
......
......@@ -11,10 +11,6 @@ import com.base.appzxhy.R
import com.base.appzxhy.business.ads.AdsMgr
import com.base.appzxhy.business.ads.AdsShowCallBack
import com.base.appzxhy.databinding.ActivityPangleBinding
import com.base.appzxhy.utils.ToastUtils.toast
import com.bytedance.sdk.openadsdk.api.init.PAGConfig
import com.bytedance.sdk.openadsdk.api.init.PAGSdk
import com.bytedance.sdk.openadsdk.api.init.PAGSdk.PAGInitCallback
class PangleActivity : AppCompatActivity() {
......@@ -42,6 +38,15 @@ class PangleActivity : AppCompatActivity() {
})
}
binding.showInter.setOnClickListener {
AdsMgr.showInsert(this, showCallBack = object : AdsShowCallBack() {
override fun next() {
}
})
}
}
......
package com.base.appzxhy.business.pangle
import android.util.Log
import android.app.Activity
import com.base.appzxhy.GlobalConfig
import com.base.appzxhy.business.ads.AdsShowCallBack
import com.base.appzxhy.utils.LogEx
import com.bytedance.sdk.openadsdk.api.interstitial.PAGInterstitialAd
import com.bytedance.sdk.openadsdk.api.interstitial.PAGInterstitialAdInteractionListener
import com.bytedance.sdk.openadsdk.api.interstitial.PAGInterstitialAdLoadListener
import com.bytedance.sdk.openadsdk.api.interstitial.PAGInterstitialRequest
......@@ -31,4 +32,56 @@ class PangleInterMgr {
}
})
}
fun show(activity: Activity, showCallBack: AdsShowCallBack?) {
if (activity.isFinishing || activity.isDestroyed) {
return
}
this.showCallBack = showCallBack
if (interstitialAd == null) {
LogEx.logDebug(TAG, "interstitialAd load")
load {
if (it) {
showReadyAd(activity)
} else {
showCallBack?.adFailed()
}
}
} else {
LogEx.logDebug(TAG, "interstitialAd ready")
showReadyAd(activity)
}
}
private fun showReadyAd(ac: Activity) {
if (ac.isFinishing || ac.isDestroyed) {
return
}
if (interstitialAd == null) {
showCallBack?.failed()
return
}
LogEx.logDebug(TAG, "interstitialAd show")
interstitialAd?.setAdInteractionListener(object : PAGInterstitialAdInteractionListener {
override fun onAdShowed() {
showCallBack?.show()
interstitialAd = null
load()
}
override fun onAdClicked() {
}
override fun onAdDismissed() {
showCallBack?.close()
}
})
interstitialAd?.show(ac)
}
}
\ No newline at end of file
......@@ -23,4 +23,12 @@
android:layout_marginVertical="@dimen/dp_3"
android:text="展示开屏" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/showInter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/dp_3"
android:text="展示插页" />
</LinearLayout>
\ No newline at end of file
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