Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions src/main/java/com/mapconductor/longdo/LongdoMapView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,17 @@ fun LongdoMapSurface(
onDispose {
moveDispatcher.cancel()
controller.destroy()
// No MapViewBase here to do it: the state (which the app keeps) must
// not hold on to the destroyed controller and its overlays.
state.detachController(controller)
// The WebView is the map. Not destroyed, it keeps its renderer and
// the JS bridge, and through them the controller with every overlay.
// This runs for a configuration change too: the old Activity's
// WebView is never shown again (the state is what survives).
(longdoMap.parent as? ViewGroup)?.removeView(longdoMap)
longdoMap.removeJavascriptInterface(BRIDGE_NAME)
longdoMap.stopLoading()
longdoMap.destroy()
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/mapconductor/longdo/LongdoViewStateImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class LongdoViewState(
LongdoViewStateInterface {
private var _mapDesignType by mutableStateOf(mapDesignType)

private var controller: LongdoMapViewController? = null
// Read through the base so that letting go of the controller there (MapViewBase
// does it when the map is torn down) leaves nothing behind here.
private val controller: LongdoMapViewController?
get() = attachedMapController as? LongdoMapViewController

override var mapDesignType: LongdoMapDesignTypeInterface
get() = _mapDesignType
Expand All @@ -49,7 +52,6 @@ class LongdoViewState(

/** MapView 生成時にコントローラを紐付ける。 */
fun setController(controller: LongdoMapViewController) {
this.controller = controller
// 初期カメラは LongdoMap.LOCATION として地図読み込み前に渡すので、接続時には移動しない。
attachController(controller, moveToInitialCamera = false)
}
Expand Down
Loading