summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorŁukasz Paczos <lukas.paczos@gmail.com>2018-09-05 11:32:48 +0200
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2018-09-12 13:59:11 +0200
commitfa3f6f055cea88ad31e8e641c1c24d1b5507629a (patch)
tree2a247123f0f7053800fbda539f79ee1ce3cf3152 /platform
parentbfe0b67572e877dbc55f27dfcfee7c75b953fc8a (diff)
downloadqtlocation-mapboxgl-fa3f6f055cea88ad31e8e641c1c24d1b5507629a.tar.gz
[android] deactivating default location engine when the map is destroyed
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java7
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java15
3 files changed, 20 insertions, 6 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index 76870e44d9..83a0ef0e62 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -426,6 +426,10 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
onMapChangedListeners.clear();
mapCallback.clearOnMapReadyCallbacks();
+ if (mapboxMap != null) {
+ mapboxMap.onDestroy();
+ }
+
if (nativeMapView != null && hasSurface) {
// null when destroying an activity programmatically mapbox-navigation-android/issues/503
nativeMapView.destroy();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
index 8892aa45fe..588a327839 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
@@ -159,6 +159,13 @@ public final class MapboxMap {
}
/**
+ * Called when the hosting Activity/Fragment onDestroy()/onDestroyView() method is called.
+ */
+ void onDestroy() {
+ locationLayerPlugin.onDestroy();
+ }
+
+ /**
* Called before the OnMapReadyCallback is invoked.
*/
void onPreMapReady() {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java
index 021729b6ba..1fcdaa7c76 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java
@@ -653,12 +653,6 @@ public final class LocationLayerPlugin {
* Internal use.
*/
public void onStart() {
- // TODO: 03.09.18 LLP when map destroyed
- /*if (context.isDestroyed()) {
- Logger.e("You are calling plugins #onStart after the map was destroyed. Re-create the plugin before using it.");
- return;
- }*/
-
isPluginStarted = true;
onLocationLayerStart();
}
@@ -674,6 +668,15 @@ public final class LocationLayerPlugin {
/**
* Internal use.
*/
+ public void onDestroy() {
+ if (locationEngine != null && usingInternalLocationEngine) {
+ locationEngine.deactivate();
+ }
+ }
+
+ /**
+ * Internal use.
+ */
public void onStartLoadingMap() {
onLocationLayerStop();
}