Skip to content

Commit

Permalink
Revert "Revert "#138 - prevent a memory leak on AndroidView which may…
Browse files Browse the repository at this point in the history
… not call ON_DESTROY (#188)" (#202)"

This reverts commit 5183ce0.
  • Loading branch information
wangela committed Sep 21, 2022
1 parent 5183ce0 commit db6dc6e
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -175,6 +175,8 @@ private fun MapLifecycle(mapView: MapView) {
onDispose {
lifecycle.removeObserver(mapLifecycleObserver)
context.unregisterComponentCallbacks(callbacks)
mapView.onDestroy()
mapView.removeAllViews()
}
}
}
Expand All @@ -195,7 +197,9 @@ private fun MapView.lifecycleObserver(previousState: MutableState<Lifecycle.Even
Lifecycle.Event.ON_RESUME -> this.onResume()
Lifecycle.Event.ON_PAUSE -> this.onPause()
Lifecycle.Event.ON_STOP -> this.onStop()
Lifecycle.Event.ON_DESTROY -> this.onDestroy()
Lifecycle.Event.ON_DESTROY -> {
//handled in onDispose
}
else -> throw IllegalStateException()
}
previousState.value = event
Expand Down

0 comments on commit db6dc6e

Please sign in to comment.