From 2f9612ef50f1f5ee62dece63339a37c9ed747f4e Mon Sep 17 00:00:00 2001 From: marrisaichandan Date: Tue, 17 Jan 2023 18:14:36 +0530 Subject: [PATCH] new cache management5.0 --- adutils/src/main/java/com/appyhigh/adutils/AdSdk.kt | 7 +++++-- .../main/java/com/appyhigh/adutils/AppOpenManager.kt | 11 +++++++---- .../main/java/com/appyhigh/adutils/MainActivity.kt | 5 +++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/adutils/src/main/java/com/appyhigh/adutils/AdSdk.kt b/adutils/src/main/java/com/appyhigh/adutils/AdSdk.kt index 628c29b..8dd8990 100644 --- a/adutils/src/main/java/com/appyhigh/adutils/AdSdk.kt +++ b/adutils/src/main/java/com/appyhigh/adutils/AdSdk.kt @@ -434,7 +434,8 @@ object AdSdk { backgroundThreshold: Int = 30000, isShownOnlyOnce: Boolean = false, isAdmanager:Boolean = false, - loadTimeOut:Int + loadTimeOut:Int, + isPremium:Boolean = false ) { if (isInitialized){ if (application != null && AppPref.getBoolean(application?.applicationContext!!,AppPref.showAppAds) && AdMobUtil.fetchAdStatusFromAdId(adName)) { @@ -447,7 +448,9 @@ object AdSdk { isShownOnlyOnce, backgroundThreshold, appOpenAdCallback, - isAdmanager + isAdmanager, + loadTimeOut, + isPremium ) appOpenAdCallback?.onInitSuccess(appOpenManager) } diff --git a/adutils/src/main/java/com/appyhigh/adutils/AppOpenManager.kt b/adutils/src/main/java/com/appyhigh/adutils/AppOpenManager.kt index da4eb45..68c2bf2 100644 --- a/adutils/src/main/java/com/appyhigh/adutils/AppOpenManager.kt +++ b/adutils/src/main/java/com/appyhigh/adutils/AppOpenManager.kt @@ -34,7 +34,9 @@ class AppOpenManager( private val isShownOnlyOnce: Boolean, private var backgroundThreshold: Int = 30000, private var appOpenAdCallback: AppOpenAdCallback?, - private var isAdmanager:Boolean + private var isAdmanager:Boolean, + private var loadTimeOut:Int, + private var isPremium:Boolean ) : LifecycleObserver, ActivityLifecycleCallbacks { @@ -77,7 +79,7 @@ class AppOpenManager( // } var fetchedTimer:Int = AdMobUtil.fetchAdLoadTimeout(adName) if (fetchedTimer == 0){ - fetchedTimer = 3500 + fetchedTimer = loadTimeOut } var primaryIds = AdMobUtil.fetchPrimaryById(adName) var secondaryIds = AdMobUtil.fetchSecondaryById(adName) @@ -321,7 +323,7 @@ class AppOpenManager( backgroundThreshold = 1000 } Log.i(LOG_TAG, "App Background Time: $appBackgroundTime ms") - if (appBackgroundTime > backgroundThreshold) + if (appBackgroundTime > backgroundThreshold && !isPremium) showAdIfAvailable() } appCount++ @@ -418,7 +420,8 @@ class AppOpenManager( */ initialized = true myApplication.registerActivityLifecycleCallbacks(this) - fetchAd() + if (!isPremium) + fetchAd() ProcessLifecycleOwner.get().lifecycle.addObserver(this) } } \ No newline at end of file diff --git a/app/src/main/java/com/appyhigh/adutils/MainActivity.kt b/app/src/main/java/com/appyhigh/adutils/MainActivity.kt index 82addc5..e739d5e 100644 --- a/app/src/main/java/com/appyhigh/adutils/MainActivity.kt +++ b/app/src/main/java/com/appyhigh/adutils/MainActivity.kt @@ -66,7 +66,7 @@ class MainActivity : AppCompatActivity(), VersionCallback { }, 1000, false, - loadTimeOut = 4000 + loadTimeOut = 4000, ) } else { AdSdk.attachAppOpenAdManager("ca-app-pub-3940256099942544/3419835294", @@ -77,7 +77,8 @@ class MainActivity : AppCompatActivity(), VersionCallback { Log.d("Appopen", "onAdFailedToLoad: "+loadAdError?.message) } }, - loadTimeOut = 4000) + loadTimeOut = 4000 + ) } binding.btnBannerAd.setOnClickListener {