[android] - check if the render surface has been correctly created before destroying the map
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user