|
@@ -0,0 +1,78 @@
|
|
|
+package com.ad.scope.load
|
|
|
+
|
|
|
+import android.app.Activity
|
|
|
+import android.content.Context
|
|
|
+import android.view.View
|
|
|
+import android.view.ViewGroup
|
|
|
+import com.ad.scope.load.request.ScopeAppOpenRequestImpl
|
|
|
+import com.beizi.fusion.SplashAd
|
|
|
+import com.composition.android.lib.ad.basic.*
|
|
|
+import com.composition.android.lib.ad.bean.AdUnitBean
|
|
|
+import com.composition.android.lib.ad.interfaces.AdListener
|
|
|
+import com.composition.android.lib.ad.interfaces.AdLoader
|
|
|
+import kotlinx.coroutines.Dispatchers
|
|
|
+import kotlinx.coroutines.withContext
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author: HuBoWen
|
|
|
+ * @date: 2023/4/25
|
|
|
+ * @description:
|
|
|
+ */
|
|
|
+class ScopeAdLoader : AdLoader {
|
|
|
+ override val advertisers: Advertisers
|
|
|
+ get() = Advertisers.AdScope
|
|
|
+
|
|
|
+ override fun showSplashAd(activity: Activity, splashViewGroup: ViewGroup?, adResult: AdResult.Success, adListener: AdListener) {
|
|
|
+ if (adResult.adObject is SplashAd) {
|
|
|
+ (adResult.adObject as SplashAd).apply {
|
|
|
+ show(splashViewGroup)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override suspend fun load(context: Context, adUnitBean: AdUnitBean): AdResult {
|
|
|
+ if (adUnitBean.isAvailable().not()) {
|
|
|
+ return AdResult.Fail(adUnitBean, msg = "AdUnitBean无效")
|
|
|
+ }
|
|
|
+ //获取到具体的广告格式加载类
|
|
|
+ val adFormatRequestImpl = withContext(Dispatchers.IO) {
|
|
|
+ when (adUnitBean.getAdType()) {
|
|
|
+ AdType.APP_OPEN -> ScopeAppOpenRequestImpl()
|
|
|
+ else -> null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return loadByStrategy(context, adUnitBean, adFormatRequestImpl)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun getBannerView(context: Context, adResult: AdResult.Success, viewHolder: BannerAdViewHolder): BasicAdView<*>? {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun getNativeAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder): View? {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun destroyAd(adResult: AdResult) {
|
|
|
+ TODO("Not yet implemented")
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun populateNativeAdView(context: Context, adResult: AdResult.Success, viewHolder: NativeAdViewHolder, advertisersContainerView: ViewGroup) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun showInterstitialAd(activity: Activity, adResult: AdResult.Success, adListener: AdListener) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun showRewardedAd(activity: Activity, adResult: AdResult.Success, adListener: AdListener) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun showRewardedInterstitialAd(activity: Activity, adResult: AdResult.Success, adListener: AdListener) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun showFullScreenAd(activity: Activity, adResult: AdResult.Success, adListener: AdListener) {
|
|
|
+ TODO("Not yet implemented")
|
|
|
+ }
|
|
|
+}
|