Commit 8b2cb38d authored by 7c00's avatar 7c00

完善 Destroy 处理

parent 399b7035
...@@ -99,12 +99,6 @@ class AMapView(context: Context) : TextureMapView(context) { ...@@ -99,12 +99,6 @@ class AMapView(context: Context) : TextureMapView(context) {
map.setInfoWindowAdapter(AMapInfoWindowAdapter(context, markers)) map.setInfoWindowAdapter(AMapInfoWindowAdapter(context, markers))
} }
@SuppressLint("MissingSuperCall")
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
map.isMyLocationEnabled = false
}
fun emitCameraChangeEvent(event: String, position: CameraPosition?) { fun emitCameraChangeEvent(event: String, position: CameraPosition?) {
position?.let { position?.let {
val data = Arguments.createMap() val data = Arguments.createMap()
......
...@@ -25,6 +25,11 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() { ...@@ -25,6 +25,11 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
return AMapView(reactContext) return AMapView(reactContext)
} }
override fun onDropViewInstance(view: AMapView) {
super.onDropViewInstance(view)
view.onDestroy()
}
override fun getCommandsMap(): Map<String, Int> { override fun getCommandsMap(): Map<String, Int> {
return mapOf("animateTo" to ANIMATE_TO) return mapOf("animateTo" to ANIMATE_TO)
} }
......
...@@ -33,6 +33,10 @@ abstract class AMapNavigation(context: ThemedReactContext) : ...@@ -33,6 +33,10 @@ abstract class AMapNavigation(context: ThemedReactContext) :
navigation.startNavi(NaviType.GPS) navigation.startNavi(NaviType.GPS)
} }
fun stop() {
navigation.stopNavi()
}
protected fun latLngFromReadableMap(map: ReadableMap): NaviLatLng { protected fun latLngFromReadableMap(map: ReadableMap): NaviLatLng {
return NaviLatLng(map.getDouble("latitude"), map.getDouble("longitude")) return NaviLatLng(map.getDouble("latitude"), map.getDouble("longitude"))
} }
......
...@@ -7,6 +7,7 @@ import com.facebook.react.uimanager.ViewGroupManager ...@@ -7,6 +7,7 @@ import com.facebook.react.uimanager.ViewGroupManager
abstract class AMapNavigationManager<T : AMapNavigation> : ViewGroupManager<T>() { abstract class AMapNavigationManager<T : AMapNavigation> : ViewGroupManager<T>() {
override fun onDropViewInstance(view: T) { override fun onDropViewInstance(view: T) {
super.onDropViewInstance(view) super.onDropViewInstance(view)
view.stop()
view.onDestroy() view.onDestroy()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment