|
@@ -0,0 +1,115 @@
|
|
|
|
+package com.kdanmobile.admanager
|
|
|
|
+
|
|
|
|
+import android.app.Activity
|
|
|
|
+import android.content.Context
|
|
|
|
+import android.view.View
|
|
|
|
+import java.util.concurrent.CopyOnWriteArrayList
|
|
|
|
+
|
|
|
|
+abstract class AbstractAdManager : AdManager {
|
|
|
|
+ protected lateinit var context: Context
|
|
|
|
+ protected lateinit var interstitialAdManager: InterstitialAdManager
|
|
|
|
+ protected lateinit var nativeAdManager: NativeAdManager
|
|
|
|
+ protected lateinit var rewardedAdManager: RewardedAdManager
|
|
|
|
+
|
|
|
|
+ override var isInitialized = false
|
|
|
|
+ override val onInitListeners = CopyOnWriteArrayList<Runnable>()
|
|
|
|
+ override var isPersonalized: Boolean = true
|
|
|
|
+ set(value) {
|
|
|
|
+ field = value
|
|
|
|
+ interstitialAdManager.isPersonalized = value
|
|
|
|
+ nativeAdManager.isPersonalized = value
|
|
|
|
+ rewardedAdManager.isPersonalized = value
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun requestInterstitial(adUnitId: String) {
|
|
|
|
+ interstitialAdManager.request(adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun requestInterstitial(activity: Activity, adUnitId: String) {
|
|
|
|
+ interstitialAdManager.request(activity, adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun showInterstitial(adUnitId: String): Boolean {
|
|
|
|
+ return interstitialAdManager.show(adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun destroyInterstitial(activity: Activity) {
|
|
|
|
+ interstitialAdManager.destroy(activity)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun registerInterstitialAdListener(interstitialAdListener: InterstitialAdListener) {
|
|
|
|
+ interstitialAdManager.registerListener(interstitialAdListener)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun unregisterInterstitialAdListener(interstitialAdListener: InterstitialAdListener) {
|
|
|
|
+ interstitialAdManager.unregisterListener(interstitialAdListener)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun isInterstitialLoading(adUnitId: String): Boolean {
|
|
|
|
+ return interstitialAdManager.isLoading(adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun isInterstitialLoaded(adUnitId: String): Boolean {
|
|
|
|
+ return interstitialAdManager.isLoaded(adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun registerNativeAdListener(nativeAdListener: NativeAdListener) {
|
|
|
|
+ nativeAdManager.listener += nativeAdListener
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun unregisterNativeAdListener(nativeAdListener: NativeAdListener) {
|
|
|
|
+ nativeAdManager.listener -= nativeAdListener
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun requestNative(adUnitId: String, nativeAdViewBinder: NativeAdViewBinder) {
|
|
|
|
+ nativeAdManager.request(adUnitId, nativeAdViewBinder)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun takeNativeAdView(adUnitId: String, nativeAdViewBinder: NativeAdViewBinder): View? {
|
|
|
|
+ return nativeAdManager.takeAdView(adUnitId, nativeAdViewBinder)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun isNativeLoading(adUnitId: String): Boolean {
|
|
|
|
+ return nativeAdManager.isLoading(adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun requestRewardedAd(activity: Activity, adUnitId: String) {
|
|
|
|
+ rewardedAdManager.request(activity, adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun requestRewardedAd(adUnitId: String) {
|
|
|
|
+ rewardedAdManager.request(adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun showRewardedAd(adUnitId: String): Boolean {
|
|
|
|
+ return rewardedAdManager.show(adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun registerRewardedAdListener(listener: RewardedAdListener) {
|
|
|
|
+ rewardedAdManager.registerListener(listener)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun unregisterRewardedAdListener(listener: RewardedAdListener) {
|
|
|
|
+ rewardedAdManager.unregisterListener(listener)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun isRewardedAdLoading(adUnitId: String): Boolean {
|
|
|
|
+ return rewardedAdManager.isLoading(adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun isRewardedAdLoaded(adUnitId: String): Boolean {
|
|
|
|
+ return rewardedAdManager.isLoaded(adUnitId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun pauseRewardedAds(context: Context) {
|
|
|
|
+ rewardedAdManager.pauseAll(context)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun resumeRewardedAds(context: Context) {
|
|
|
|
+ rewardedAdManager.resumeAll(context)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun destroyRewardedAds(context: Context) {
|
|
|
|
+ rewardedAdManager.destroyAll(context)
|
|
|
|
+ }
|
|
|
|
+}
|