[android] deactivating default location engine when the map is destroyed
This commit is contained in:
committed by
Łukasz Paczos
parent
bfe0b67572
commit
fa3f6f055c
@@ -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();
|
||||
|
||||
@@ -158,6 +158,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.
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -671,6 +665,15 @@ public final class LocationLayerPlugin {
|
||||
isPluginStarted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal use.
|
||||
*/
|
||||
public void onDestroy() {
|
||||
if (locationEngine != null && usingInternalLocationEngine) {
|
||||
locationEngine.deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal use.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user