[android] - check if the render surface has been correctly created before destroying the map

This commit is contained in:
Tobrun
2018-01-10 14:53:28 +01:00
committed by Tobrun
parent 46ace8d2c7
commit b03c226373

View File

@@ -75,6 +75,7 @@ public class MapView extends FrameLayout {
private NativeMapView nativeMapView;
private MapboxMapOptions mapboxMapOptions;
private boolean destroyed;
private boolean hasSurface;
private MyLocationView myLocationView;
private CompassView compassView;
@@ -321,6 +322,7 @@ public class MapView extends FrameLayout {
}
private void initRenderSurface() {
hasSurface = true;
post(new Runnable() {
@Override
public void run() {
@@ -409,7 +411,7 @@ public class MapView extends FrameLayout {
destroyed = true;
mapCallback.clearOnMapReadyCallbacks();
if (nativeMapView != null) {
if (nativeMapView != null && hasSurface) {
// null when destroying an activity programmatically mapbox-navigation-android/issues/503
nativeMapView.destroy();
nativeMapView = null;