Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions app/src/ads/java/app/opendocument/droid/nonfree/AdManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,24 @@ class AdManager {
return
}

val adView = this.adView ?: addAdView().also { this.adView = it }

// an anchored banner keeps the size it was asked at, so a real width change needs a new
// one - but a keyboard opening, or a rotation back, does not
if (adWidth == requestedWidth) {
val previous = this.adView
if (previous != null && adWidth == requestedWidth) {
return
}
requestedWidth = adWidth

// AdView.setAdSize throws once the view has a size, so a width change replaces the banner
// rather than resizing it, and the ad that was up goes with it
if (previous != null) {
destroyAdView()
adContainer.removeView(previous)
hasAd = false
}

val adView = addAdView().also { this.adView = it }

adView.setAdSize(adSize)

retries.removeCallbacksAndMessages(null)
Expand Down
Loading