Skip to content

Commit

Permalink
Merge pull request #191 from superwall/ir/fix/fix-background-restorat…
Browse files Browse the repository at this point in the history
…ion-issues

Fix background restoration issues and ensure safety of destroy calls
  • Loading branch information
ianrumac authored Oct 17, 2024
2 parents ed46be0 + 8c45ac6 commit a4c3809
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/Superwall-Android/releases) on GitHub.

## 1.3.1

### Fixes
- Fixes issue when destroying activities during sleep would cause a background crash

## 1.3.0

### Enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ class SuperwallPaywallActivity : AppCompatActivity() {
}

override fun onDestroy() {
super.onDestroy()
val content = contentView as? ViewGroup?
if (content != null && content is CoordinatorLayout) {
val bottomSheetBehavior = BottomSheetBehavior.from(content.getChildAt(0))
Expand All @@ -434,11 +433,19 @@ class SuperwallPaywallActivity : AppCompatActivity() {
}
val pv = intent.getStringExtra(VIEW_KEY)
if (pv != null) {
(
Superwall.instance.dependencyContainer
.makeViewStore()
.retrieveView(pv) as PaywallView
).cleanup()
try {
(
Superwall.instance.dependencyContainer
.makeViewStore()
.retrieveView(pv) as? PaywallView?
)?.cleanup()
} catch (e: Throwable) {
Logger.debug(
LogLevel.debug,
LogScope.paywallView,
"Cache cleanup failed - application going to sleep.",
)
}
}
paywallView()?.webView?.onScrollChangeListener = null
paywallView()?.cleanup()
Expand All @@ -447,6 +454,7 @@ class SuperwallPaywallActivity : AppCompatActivity() {
(paywallView() as? ActivityEncapsulatable)?.encapsulatingActivity = null
// Clear the reference to the contentView
contentView = null
super.onDestroy()
}

//region Notifications
Expand Down

0 comments on commit a4c3809

Please sign in to comment.