[android] check for Mapbox#INSTANCE when initializing the MapView

This commit is contained in:
Łukasz Paczos
2019-04-08 16:01:58 +02:00
committed by Łukasz Paczos
parent 104091cd93
commit f22c014b91
4 changed files with 54 additions and 2 deletions

View File

@@ -180,4 +180,11 @@ public final class Mapbox {
accessToken = accessToken.trim().toLowerCase(MapboxConstants.MAPBOX_LOCALE);
return accessToken.length() != 0 && (accessToken.startsWith("pk.") || accessToken.startsWith("sk."));
}
/**
* Internal use. Check if the {@link Mapbox#INSTANCE} is present.
*/
public static boolean hasInstance() {
return INSTANCE != null;
}
}

View File

@@ -26,6 +26,7 @@ import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer;
@@ -120,6 +121,10 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
return;
}
if (!Mapbox.hasInstance()) {
throw new MapboxConfigurationException();
}
// hide surface until map is fully loaded #10990
setForeground(new ColorDrawable(options.getForegroundLoadColor()));

View File

@@ -3,8 +3,9 @@ package com.mapbox.mapboxsdk.maps.renderer;
import android.content.Context;
import android.support.annotation.CallSuper;
import android.support.annotation.Keep;
import android.support.annotation.NonNull;
import com.mapbox.mapboxsdk.LibraryLoader;
import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.storage.FileSource;
@@ -22,6 +23,10 @@ import javax.microedition.khronos.opengles.GL10;
@Keep
public abstract class MapRenderer implements MapRendererScheduler {
static {
LibraryLoader.load();
}
private static final String TAG = "Mbgl-MapRenderer";
// Holds the pointer to the native peer after initialisation