Skip to content

Commit

Permalink
#138 - prevent a memory leak on AndroidView which may not call ON_DES…
Browse files Browse the repository at this point in the history
…TROY (#188)
  • Loading branch information
polivmi1 committed Sep 21, 2022
1 parent 24f2015 commit b87f837
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 b87f837

Please sign in to comment.