[android] check if the map is destroyed before saving state in a fragment

This commit is contained in:
Łukasz Paczos
2018-09-04 10:59:18 +02:00
committed by Łukasz Paczos
parent 69b7c2fe46
commit 18b43f29cf
2 changed files with 12 additions and 4 deletions

View File

@@ -165,7 +165,9 @@ public final class MapFragment extends Fragment implements OnMapReadyCallback {
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
map.onSaveInstanceState(outState);
if (map != null && !map.isDestroyed()) {
map.onSaveInstanceState(outState);
}
}
/**
@@ -183,7 +185,9 @@ public final class MapFragment extends Fragment implements OnMapReadyCallback {
@Override
public void onLowMemory() {
super.onLowMemory();
map.onLowMemory();
if (map != null && !map.isDestroyed()) {
map.onLowMemory();
}
}
/**

View File

@@ -160,7 +160,9 @@ public class SupportMapFragment extends Fragment implements OnMapReadyCallback {
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
map.onSaveInstanceState(outState);
if (map != null && !map.isDestroyed()) {
map.onSaveInstanceState(outState);
}
}
/**
@@ -178,7 +180,9 @@ public class SupportMapFragment extends Fragment implements OnMapReadyCallback {
@Override
public void onLowMemory() {
super.onLowMemory();
map.onLowMemory();
if (map != null && !map.isDestroyed()) {
map.onLowMemory();
}
}
/**