Commit 4713605a authored by wanglei's avatar wanglei

...

parent 6f711405
...@@ -23,6 +23,7 @@ import com.base.filerecoveryrecyclebin.ads.admob.AdmobInterstitialUtils ...@@ -23,6 +23,7 @@ import com.base.filerecoveryrecyclebin.ads.admob.AdmobInterstitialUtils
import com.base.filerecoveryrecyclebin.ads.admob.AdmobNativeUtils import com.base.filerecoveryrecyclebin.ads.admob.AdmobNativeUtils
import com.base.filerecoveryrecyclebin.ads.max.AdMaxInit import com.base.filerecoveryrecyclebin.ads.max.AdMaxInit
import com.base.filerecoveryrecyclebin.ads.max.AdMaxInterstitialUtils import com.base.filerecoveryrecyclebin.ads.max.AdMaxInterstitialUtils
import com.base.filerecoveryrecyclebin.ads.max.AdMaxNativeUtils
import com.base.filerecoveryrecyclebin.ads.max.AdMaxOpenUtils import com.base.filerecoveryrecyclebin.ads.max.AdMaxOpenUtils
import com.base.filerecoveryrecyclebin.bean.ConstObject import com.base.filerecoveryrecyclebin.bean.ConstObject
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_JUNK_CLEAN_PUSH import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_JUNK_CLEAN_PUSH
...@@ -115,6 +116,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() { ...@@ -115,6 +116,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
AdMaxInit.maxInitAction = { AdMaxInit.maxInitAction = {
AdMaxOpenUtils.loadAppOpenAd(this) AdMaxOpenUtils.loadAppOpenAd(this)
AdMaxInterstitialUtils.loadInterstitialAd(this) AdMaxInterstitialUtils.loadInterstitialAd(this)
AdMaxNativeUtils.loadNativeAd()
} }
} }
} }
......
...@@ -33,13 +33,6 @@ object AdmobMaxHelper { ...@@ -33,13 +33,6 @@ object AdmobMaxHelper {
} }
} }
fun isOpenAdLoaded(): Boolean {
return if (ConfigHelper.admobTrueMaxFlase) {
AdmobOpenUtils.isOpenAdLoaded()
} else {
AdMaxOpenUtils.isOpenAdLoaded()
}
}
fun admobMaxShowInterstitialAd(activity: Activity, onHidden: (() -> Unit)? = null) { fun admobMaxShowInterstitialAd(activity: Activity, onHidden: (() -> Unit)? = null) {
if (ConfigHelper.admobTrueMaxFlase) { if (ConfigHelper.admobTrueMaxFlase) {
......
...@@ -17,6 +17,7 @@ import com.base.filerecoveryrecyclebin.help.BaseApplication ...@@ -17,6 +17,7 @@ import com.base.filerecoveryrecyclebin.help.BaseApplication
import com.base.filerecoveryrecyclebin.help.ConfigHelper import com.base.filerecoveryrecyclebin.help.ConfigHelper
import com.base.filerecoveryrecyclebin.utils.EventUtils import com.base.filerecoveryrecyclebin.utils.EventUtils
import com.base.filerecoveryrecyclebin.utils.LogEx import com.base.filerecoveryrecyclebin.utils.LogEx
import com.ironsource.na
import org.json.JSONObject import org.json.JSONObject
object AdMaxNativeUtils { object AdMaxNativeUtils {
...@@ -48,6 +49,8 @@ object AdMaxNativeUtils { ...@@ -48,6 +49,8 @@ object AdMaxNativeUtils {
override fun onNativeAdLoadFailed(p0: String, p1: MaxError) { override fun onNativeAdLoadFailed(p0: String, p1: MaxError) {
super.onNativeAdLoadFailed(p0, p1) super.onNativeAdLoadFailed(p0, p1)
loadingListener?.invoke()
loadingListener = null
LogEx.logDebug(TAG, "onNativeAdLoadFailed") LogEx.logDebug(TAG, "onNativeAdLoadFailed")
AdDisplayUtils.getInstance().incrementAdRequestFailCount() AdDisplayUtils.getInstance().incrementAdRequestFailCount()
val obj2 = JSONObject() val obj2 = JSONObject()
...@@ -101,7 +104,7 @@ object AdMaxNativeUtils { ...@@ -101,7 +104,7 @@ object AdMaxNativeUtils {
.setBodyTextViewId(R.id.ad_body) .setBodyTextViewId(R.id.ad_body)
// .setAdvertiserTextViewId(R.id.advertiser_text_view) // .setAdvertiserTextViewId(R.id.advertiser_text_view)
.setIconImageViewId(R.id.ad_app_icon) .setIconImageViewId(R.id.ad_app_icon)
.setMediaContentViewGroupId(R.id.ad_media) .setMediaContentViewGroupId(R.id.media_view_container)
// .setOptionsContentViewGroupId(R.id.options_view) // .setOptionsContentViewGroupId(R.id.options_view)
// .setStarRatingContentViewGroupId(R.id.star_rating_view) // .setStarRatingContentViewGroupId(R.id.star_rating_view)
.setCallToActionButtonId(R.id.ad_call_to_action) .setCallToActionButtonId(R.id.ad_call_to_action)
...@@ -109,49 +112,52 @@ object AdMaxNativeUtils { ...@@ -109,49 +112,52 @@ object AdMaxNativeUtils {
return MaxNativeAdView(binder, context) return MaxNativeAdView(binder, context)
} }
fun loadNativeAd() {
setNativeAdListener()
if (!AdDisplayUtils.getInstance().shouldShowAd("nativeAd")) {
return
}
nativeAdLoader.loadAd()
}
fun showNativeAd(activity: Activity, parent: ViewGroup, layout: Int) { fun showNativeAd(activity: Activity, parent: ViewGroup, layout: Int) {
activityString = activity::class.java.toString().split(".").last() activityString = activity::class.java.toString().split(".").last()
LogEx.logDebug(TAG, "activityString=$activityString")
setNativeAdListener() setNativeAdListener()
if (!AdDisplayUtils.getInstance().shouldShowAd("nativeAd")) { if (!AdDisplayUtils.getInstance().shouldShowAd("nativeAd")) {
LogEx.logDebug(TAG, "!shouldShowAd")
return return
} }
loadingListener = {
//展示广告
val adView = createNativeAdView(activity, layout)
if (System.currentTimeMillis() - nativeLoadTime <= 1000 * 60 * 60) {
if (nativeAd?.nativeAd?.isExpired == true || nativeAd == null) {
//是否已经加载渲染 LogEx.logDebug(TAG, "nativeAd?.nativeAd?.isExpired == true")
if (nativeAd?.nativeAd?.isExpired == true) {
nativeAdLoader.destroy(nativeAd) nativeAdLoader.destroy(nativeAd)
nativeAdLoader.loadAd(adView) nativeAdLoader.loadAd()
loadingListener = {
if (nativeAd != null) {
showReadNative(activity, parent, layout)
}
}
} else { } else {
showReadNative(activity, parent, layout)
}
}
private fun showReadNative(activity: Activity, parent: ViewGroup, layout: Int) {
val adView = createNativeAdView(activity, layout)
LogEx.logDebug(TAG, "showReadNative adUnitId=${nativeAd?.adUnitId}")
parent.isVisible = true parent.isVisible = true
nativeAdLoader.render(adView, nativeAd)
parent.removeAllViews() parent.removeAllViews()
nativeAdLoader.render(adView, nativeAd)
parent.addView(adView) parent.addView(adView)
nativeAd?.let { AdMaxEvent.showAd(it, "nativeAd", activityString) } nativeAd?.let { AdMaxEvent.showAd(it, "nativeAd", activityString) }
AdDisplayUtils.getInstance().incrementAdDisplayCount() AdDisplayUtils.getInstance().incrementAdDisplayCount()
}
}
nativeAdLoader.loadAd(adView)
LogEx.logDebug(TAG, "loadingListener finish") LogEx.logDebug(TAG, "loadingListener finish")
} }
if (nativeAd == null) {
nativeAdLoader.loadAd()
val obj2 = JSONObject()
obj2.put("reason", "no_ad")
obj2.put("ad_unit", "nativeAd")
EventUtils.event("ad_show_error", ext = obj2)
} else {
loadingListener?.invoke()
}
}
} }
\ No newline at end of file
...@@ -8,6 +8,7 @@ object LogEx { ...@@ -8,6 +8,7 @@ object LogEx {
val filterTAG = arrayOf( val filterTAG = arrayOf(
"FileScanActivity", "FileScanActivity",
// "FileHexEx", // "FileHexEx",
"FileScanResultActivity",
"FileGridAdapter" "FileGridAdapter"
) )
......
...@@ -51,10 +51,10 @@ ...@@ -51,10 +51,10 @@
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<TextView <TextView
android:layout_marginStart="8dp"
android:id="@+id/ad_headline" android:id="@+id/ad_headline"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textColor="@color/black" android:textColor="@color/black"
...@@ -77,8 +77,8 @@ ...@@ -77,8 +77,8 @@
</LinearLayout> </LinearLayout>
<com.google.android.gms.ads.nativead.MediaView <FrameLayout
android:id="@+id/ad_media" android:id="@+id/media_view_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="100dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
android:layout_gravity="center_vertical"> android:layout_gravity="center_vertical">
<FrameLayout <FrameLayout
android:id="@+id/ad_media" android:id="@+id/media_view_container"
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="60dp" android:layout_height="60dp"
android:layout_gravity="center" /> android:layout_gravity="center" />
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
android:layout_gravity="center_vertical"> android:layout_gravity="center_vertical">
<FrameLayout <FrameLayout
android:id="@+id/ad_media" android:id="@+id/media_view_container"
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="60dp" android:layout_height="60dp"
android:layout_gravity="center" /> android:layout_gravity="center" />
......
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