Skip to content

Commit

Permalink
new cache management5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marrisaichandan committed Jan 17, 2023
1 parent 5474443 commit 2f9612e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
7 changes: 5 additions & 2 deletions adutils/src/main/java/com/appyhigh/adutils/AdSdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -447,7 +448,9 @@ object AdSdk {
isShownOnlyOnce,
backgroundThreshold,
appOpenAdCallback,
isAdmanager
isAdmanager,
loadTimeOut,
isPremium
)
appOpenAdCallback?.onInitSuccess(appOpenManager)
}
Expand Down
11 changes: 7 additions & 4 deletions adutils/src/main/java/com/appyhigh/adutils/AppOpenManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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++
Expand Down Expand Up @@ -418,7 +420,8 @@ class AppOpenManager(
*/
initialized = true
myApplication.registerActivityLifecycleCallbacks(this)
fetchAd()
if (!isPremium)
fetchAd()
ProcessLifecycleOwner.get().lifecycle.addObserver(this)
}
}
5 changes: 3 additions & 2 deletions app/src/main/java/com/appyhigh/adutils/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MainActivity : AppCompatActivity(), VersionCallback {
},
1000,
false,
loadTimeOut = 4000
loadTimeOut = 4000,
)
} else {
AdSdk.attachAppOpenAdManager("ca-app-pub-3940256099942544/3419835294",
Expand All @@ -77,7 +77,8 @@ class MainActivity : AppCompatActivity(), VersionCallback {
Log.d("Appopen", "onAdFailedToLoad: "+loadAdError?.message)
}
},
loadTimeOut = 4000)
loadTimeOut = 4000
)
}

binding.btnBannerAd.setOnClickListener {
Expand Down

0 comments on commit 2f9612e

Please sign in to comment.