From cae669262ec06852d33b9ac3112e5a94f7bb4261 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Mon, 10 Jun 2024 00:22:06 +0200 Subject: [PATCH] Fix #445 stop listening for updates before stopping/destroying the view --- .../org/maplibre/maplibregl/MapLibreMapController.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/maplibre_gl/android/src/main/java/org/maplibre/maplibregl/MapLibreMapController.java b/maplibre_gl/android/src/main/java/org/maplibre/maplibregl/MapLibreMapController.java index cd87dccf..724c39c1 100644 --- a/maplibre_gl/android/src/main/java/org/maplibre/maplibregl/MapLibreMapController.java +++ b/maplibre_gl/android/src/main/java/org/maplibre/maplibregl/MapLibreMapController.java @@ -1770,15 +1770,17 @@ private void destroyMapViewIfNecessary() { if (mapView == null) { return; } - mapViewContainer.removeView(mapView); - mapView.onStop(); - mapView.onDestroy(); if (locationComponent != null) { locationComponent.setLocationComponentEnabled(false); } stopListeningForLocationUpdates(); + mapViewContainer.removeView(mapView); + + mapView.onStop(); + mapView.onDestroy(); + mapView = null; }