[android] clear the style object when the map is destroyed

This commit is contained in:
Łukasz Paczos
2019-03-20 16:07:47 +01:00
committed by Łukasz Paczos
parent d5868d3da8
commit db275e5888
2 changed files with 8 additions and 4 deletions

View File

@@ -174,6 +174,9 @@ public final class MapboxMap {
*/
void onDestroy() {
locationComponent.onDestroy();
if (style != null) {
style.clear();
}
}
/**
@@ -813,7 +816,7 @@ public final class MapboxMap {
public void setStyle(Style.Builder builder, final Style.OnStyleLoaded callback) {
locationComponent.onStartLoadingMap();
if (style != null) {
style.onWillStartLoadingMap();
style.clear();
}
if (callback != null) {

View File

@@ -437,10 +437,11 @@ public class Style {
//
/**
* Called when the underlying map will start loading a new style. This method will clean up this style
* by setting the java sources and layers in a detached state and removing them from core.
* Called when the underlying map will start loading a new style or the map is destroyed.
* This method will clean up this style by setting the java sources and layers
* in a detached state and removing them from core.
*/
void onWillStartLoadingMap() {
void clear() {
fullyLoaded = false;
for (Source source : sources.values()) {
if (source != null) {