summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java')
-rwxr-xr-xplatform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java213
1 files changed, 113 insertions, 100 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index d258064908..d72e1a74a9 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -11,7 +11,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.DisplayMetrics;
-
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Geometry;
import com.mapbox.mapboxsdk.LibraryLoader;
@@ -20,6 +19,7 @@ import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.Polygon;
import com.mapbox.mapboxsdk.annotations.Polyline;
import com.mapbox.mapboxsdk.camera.CameraPosition;
+import com.mapbox.mapboxsdk.exceptions.CalledFromWorkerThreadException;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
@@ -32,6 +32,7 @@ import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.utils.BitmapUtils;
+import timber.log.Timber;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -41,8 +42,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
-import timber.log.Timber;
-
// Class that wraps the native methods for convenience
final class NativeMapView {
@@ -52,6 +51,9 @@ final class NativeMapView {
// Used to schedule work on the MapRenderer Thread
private final MapRenderer mapRenderer;
+ // Used to validate if methods are called from the correct thread
+ private final Thread thread;
+
// Used for callbacks
private ViewCallback viewCallback;
@@ -87,6 +89,7 @@ final class NativeMapView {
this.viewCallback = viewCallback;
this.fileSource = FileSource.getInstance(context);
this.pixelRatio = pixelRatio;
+ this.thread = Thread.currentThread();
nativeInitialize(this, fileSource, mapRenderer, pixelRatio);
}
@@ -94,7 +97,17 @@ final class NativeMapView {
// Methods
//
- private boolean isDestroyedOn(String callingMethod) {
+ private boolean checkState(String callingMethod) {
+ // validate if invocation has occurred on the main thread
+ if (thread != Thread.currentThread()) {
+ throw new CalledFromWorkerThreadException(
+ String.format(
+ "Map interactions should happen on the UI thread. Method invoked from wrong thread is %s.",
+ callingMethod)
+ );
+ }
+
+ // validate if map has already been destroyed
if (destroyed && !TextUtils.isEmpty(callingMethod)) {
Timber.e(
"You're calling `%s` after the `MapView` was destroyed, were you invoking it after `onDestroy()`?",
@@ -112,7 +125,7 @@ final class NativeMapView {
}
public void update() {
- if (isDestroyedOn("update")) {
+ if (checkState("update")) {
return;
}
@@ -120,7 +133,7 @@ final class NativeMapView {
}
public void resizeView(int width, int height) {
- if (isDestroyedOn("resizeView")) {
+ if (checkState("resizeView")) {
return;
}
width = (int) (width / pixelRatio);
@@ -152,84 +165,84 @@ final class NativeMapView {
}
public void setStyleUrl(String url) {
- if (isDestroyedOn("setStyleUrl")) {
+ if (checkState("setStyleUrl")) {
return;
}
nativeSetStyleUrl(url);
}
public String getStyleUrl() {
- if (isDestroyedOn("getStyleUrl")) {
+ if (checkState("getStyleUrl")) {
return null;
}
return nativeGetStyleUrl();
}
public void setStyleJson(String newStyleJson) {
- if (isDestroyedOn("setStyleJson")) {
+ if (checkState("setStyleJson")) {
return;
}
nativeSetStyleJson(newStyleJson);
}
public String getStyleJson() {
- if (isDestroyedOn("getStyleJson")) {
+ if (checkState("getStyleJson")) {
return null;
}
return nativeGetStyleJson();
}
public void setLatLngBounds(LatLngBounds latLngBounds) {
- if (isDestroyedOn("setLatLngBounds")) {
+ if (checkState("setLatLngBounds")) {
return;
}
nativeSetLatLngBounds(latLngBounds);
}
public void cancelTransitions() {
- if (isDestroyedOn("cancelTransitions")) {
+ if (checkState("cancelTransitions")) {
return;
}
nativeCancelTransitions();
}
public void setGestureInProgress(boolean inProgress) {
- if (isDestroyedOn("setGestureInProgress")) {
+ if (checkState("setGestureInProgress")) {
return;
}
nativeSetGestureInProgress(inProgress);
}
public void moveBy(double dx, double dy) {
- if (isDestroyedOn("moveBy")) {
+ if (checkState("moveBy")) {
return;
}
moveBy(dx, dy, 0);
}
public void moveBy(double dx, double dy, long duration) {
- if (isDestroyedOn("moveBy")) {
+ if (checkState("moveBy")) {
return;
}
nativeMoveBy(dx / pixelRatio, dy / pixelRatio, duration);
}
public void setLatLng(LatLng latLng) {
- if (isDestroyedOn("setLatLng")) {
+ if (checkState("setLatLng")) {
return;
}
setLatLng(latLng, 0);
}
public void setLatLng(LatLng latLng, long duration) {
- if (isDestroyedOn("setLatLng")) {
+ if (checkState("setLatLng")) {
return;
}
nativeSetLatLng(latLng.getLatitude(), latLng.getLongitude(), duration);
}
public LatLng getLatLng() {
- if (isDestroyedOn("")) {
+ if (checkState("")) {
return new LatLng();
}
// wrap longitude values coming from core
@@ -237,7 +250,7 @@ final class NativeMapView {
}
public CameraPosition getCameraForLatLngBounds(LatLngBounds latLngBounds, int[] padding) {
- if (isDestroyedOn("getCameraForLatLngBounds")) {
+ if (checkState("getCameraForLatLngBounds")) {
return null;
}
return nativeGetCameraForLatLngBounds(
@@ -249,7 +262,7 @@ final class NativeMapView {
}
public CameraPosition getCameraForGeometry(Geometry geometry, double bearing, int[] padding) {
- if (isDestroyedOn("getCameraForGeometry")) {
+ if (checkState("getCameraForGeometry")) {
return null;
}
return nativeGetCameraForGeometry(
@@ -261,77 +274,77 @@ final class NativeMapView {
}
public void resetPosition() {
- if (isDestroyedOn("resetPosition")) {
+ if (checkState("resetPosition")) {
return;
}
nativeResetPosition();
}
public double getPitch() {
- if (isDestroyedOn("getPitch")) {
+ if (checkState("getPitch")) {
return 0;
}
return nativeGetPitch();
}
public void setPitch(double pitch, long duration) {
- if (isDestroyedOn("setPitch")) {
+ if (checkState("setPitch")) {
return;
}
nativeSetPitch(pitch, duration);
}
public void setZoom(double zoom, PointF focalPoint, long duration) {
- if (isDestroyedOn("setZoom")) {
+ if (checkState("setZoom")) {
return;
}
nativeSetZoom(zoom, focalPoint.x / pixelRatio, focalPoint.y / pixelRatio, duration);
}
public double getZoom() {
- if (isDestroyedOn("getZoom")) {
+ if (checkState("getZoom")) {
return 0;
}
return nativeGetZoom();
}
public void resetZoom() {
- if (isDestroyedOn("resetZoom")) {
+ if (checkState("resetZoom")) {
return;
}
nativeResetZoom();
}
public void setMinZoom(double zoom) {
- if (isDestroyedOn("setMinZoom")) {
+ if (checkState("setMinZoom")) {
return;
}
nativeSetMinZoom(zoom);
}
public double getMinZoom() {
- if (isDestroyedOn("getMinZoom")) {
+ if (checkState("getMinZoom")) {
return 0;
}
return nativeGetMinZoom();
}
public void setMaxZoom(double zoom) {
- if (isDestroyedOn("setMaxZoom")) {
+ if (checkState("setMaxZoom")) {
return;
}
nativeSetMaxZoom(zoom);
}
public double getMaxZoom() {
- if (isDestroyedOn("getMaxZoom")) {
+ if (checkState("getMaxZoom")) {
return 0;
}
return nativeGetMaxZoom();
}
public void rotateBy(double sx, double sy, double ex, double ey) {
- if (isDestroyedOn("rotateBy")) {
+ if (checkState("rotateBy")) {
return;
}
rotateBy(sx, sy, ex, ey, 0);
@@ -339,14 +352,14 @@ final class NativeMapView {
public void rotateBy(double sx, double sy, double ex, double ey,
long duration) {
- if (isDestroyedOn("rotateBy")) {
+ if (checkState("rotateBy")) {
return;
}
nativeRotateBy(sx / pixelRatio, sy / pixelRatio, ex, ey, duration);
}
public void setContentPadding(int[] padding) {
- if (isDestroyedOn("setContentPadding")) {
+ if (checkState("setContentPadding")) {
return;
}
nativeSetContentPadding(
@@ -357,49 +370,49 @@ final class NativeMapView {
}
public void setBearing(double degrees) {
- if (isDestroyedOn("setBearing")) {
+ if (checkState("setBearing")) {
return;
}
setBearing(degrees, 0);
}
public void setBearing(double degrees, long duration) {
- if (isDestroyedOn("setBearing")) {
+ if (checkState("setBearing")) {
return;
}
nativeSetBearing(degrees, duration);
}
public void setBearing(double degrees, double cx, double cy) {
- if (isDestroyedOn("setBearing")) {
+ if (checkState("setBearing")) {
return;
}
setBearing(degrees, cx, cy, 0);
}
public void setBearing(double degrees, double fx, double fy, long duration) {
- if (isDestroyedOn("setBearing")) {
+ if (checkState("setBearing")) {
return;
}
nativeSetBearingXY(degrees, fx / pixelRatio, fy / pixelRatio, duration);
}
public double getBearing() {
- if (isDestroyedOn("getBearing")) {
+ if (checkState("getBearing")) {
return 0;
}
return nativeGetBearing();
}
public void resetNorth() {
- if (isDestroyedOn("resetNorth")) {
+ if (checkState("resetNorth")) {
return;
}
nativeResetNorth();
}
public long addMarker(Marker marker) {
- if (isDestroyedOn("addMarker")) {
+ if (checkState("addMarker")) {
return 0;
}
Marker[] markers = {marker};
@@ -407,14 +420,14 @@ final class NativeMapView {
}
public long[] addMarkers(List<Marker> markers) {
- if (isDestroyedOn("addMarkers")) {
+ if (checkState("addMarkers")) {
return new long[] {};
}
return nativeAddMarkers(markers.toArray(new Marker[markers.size()]));
}
public long addPolyline(Polyline polyline) {
- if (isDestroyedOn("addPolyline")) {
+ if (checkState("addPolyline")) {
return 0;
}
Polyline[] polylines = {polyline};
@@ -422,14 +435,14 @@ final class NativeMapView {
}
public long[] addPolylines(List<Polyline> polylines) {
- if (isDestroyedOn("addPolylines")) {
+ if (checkState("addPolylines")) {
return new long[] {};
}
return nativeAddPolylines(polylines.toArray(new Polyline[polylines.size()]));
}
public long addPolygon(Polygon polygon) {
- if (isDestroyedOn("addPolygon")) {
+ if (checkState("addPolygon")) {
return 0;
}
Polygon[] polygons = {polygon};
@@ -437,14 +450,14 @@ final class NativeMapView {
}
public long[] addPolygons(List<Polygon> polygons) {
- if (isDestroyedOn("addPolygons")) {
+ if (checkState("addPolygons")) {
return new long[] {};
}
return nativeAddPolygons(polygons.toArray(new Polygon[polygons.size()]));
}
public void updateMarker(Marker marker) {
- if (isDestroyedOn("updateMarker")) {
+ if (checkState("updateMarker")) {
return;
}
LatLng position = marker.getPosition();
@@ -453,21 +466,21 @@ final class NativeMapView {
}
public void updatePolygon(Polygon polygon) {
- if (isDestroyedOn("updatePolygon")) {
+ if (checkState("updatePolygon")) {
return;
}
nativeUpdatePolygon(polygon.getId(), polygon);
}
public void updatePolyline(Polyline polyline) {
- if (isDestroyedOn("updatePolyline")) {
+ if (checkState("updatePolyline")) {
return;
}
nativeUpdatePolyline(polyline.getId(), polyline);
}
public void removeAnnotation(long id) {
- if (isDestroyedOn("removeAnnotation")) {
+ if (checkState("removeAnnotation")) {
return;
}
long[] ids = {id};
@@ -475,105 +488,105 @@ final class NativeMapView {
}
public void removeAnnotations(long[] ids) {
- if (isDestroyedOn("removeAnnotations")) {
+ if (checkState("removeAnnotations")) {
return;
}
nativeRemoveAnnotations(ids);
}
public long[] queryPointAnnotations(RectF rect) {
- if (isDestroyedOn("queryPointAnnotations")) {
+ if (checkState("queryPointAnnotations")) {
return new long[] {};
}
return nativeQueryPointAnnotations(rect);
}
public long[] queryShapeAnnotations(RectF rectF) {
- if (isDestroyedOn("queryShapeAnnotations")) {
+ if (checkState("queryShapeAnnotations")) {
return new long[] {};
}
return nativeQueryShapeAnnotations(rectF);
}
public void addAnnotationIcon(String symbol, int width, int height, float scale, byte[] pixels) {
- if (isDestroyedOn("addAnnotationIcon")) {
+ if (checkState("addAnnotationIcon")) {
return;
}
nativeAddAnnotationIcon(symbol, width, height, scale, pixels);
}
public void removeAnnotationIcon(String symbol) {
- if (isDestroyedOn("removeAnnotationIcon")) {
+ if (checkState("removeAnnotationIcon")) {
return;
}
nativeRemoveAnnotationIcon(symbol);
}
public void setVisibleCoordinateBounds(LatLng[] coordinates, RectF padding, double direction, long duration) {
- if (isDestroyedOn("setVisibleCoordinateBounds")) {
+ if (checkState("setVisibleCoordinateBounds")) {
return;
}
nativeSetVisibleCoordinateBounds(coordinates, padding, direction, duration);
}
public void onLowMemory() {
- if (isDestroyedOn("onLowMemory")) {
+ if (checkState("onLowMemory")) {
return;
}
nativeOnLowMemory();
}
public void setDebug(boolean debug) {
- if (isDestroyedOn("setDebug")) {
+ if (checkState("setDebug")) {
return;
}
nativeSetDebug(debug);
}
public void cycleDebugOptions() {
- if (isDestroyedOn("cycleDebugOptions")) {
+ if (checkState("cycleDebugOptions")) {
return;
}
nativeCycleDebugOptions();
}
public boolean getDebug() {
- if (isDestroyedOn("getDebug")) {
+ if (checkState("getDebug")) {
return false;
}
return nativeGetDebug();
}
public boolean isFullyLoaded() {
- if (isDestroyedOn("isFullyLoaded")) {
+ if (checkState("isFullyLoaded")) {
return false;
}
return nativeIsFullyLoaded();
}
public void setReachability(boolean status) {
- if (isDestroyedOn("setReachability")) {
+ if (checkState("setReachability")) {
return;
}
nativeSetReachability(status);
}
public double getMetersPerPixelAtLatitude(double lat) {
- if (isDestroyedOn("getMetersPerPixelAtLatitude")) {
+ if (checkState("getMetersPerPixelAtLatitude")) {
return 0;
}
return nativeGetMetersPerPixelAtLatitude(lat, getZoom()) / pixelRatio;
}
public ProjectedMeters projectedMetersForLatLng(LatLng latLng) {
- if (isDestroyedOn("projectedMetersForLatLng")) {
+ if (checkState("projectedMetersForLatLng")) {
return null;
}
return nativeProjectedMetersForLatLng(latLng.getLatitude(), latLng.getLongitude());
}
public LatLng latLngForProjectedMeters(ProjectedMeters projectedMeters) {
- if (isDestroyedOn("latLngForProjectedMeters")) {
+ if (checkState("latLngForProjectedMeters")) {
return new LatLng();
}
return nativeLatLngForProjectedMeters(projectedMeters.getNorthing(),
@@ -581,7 +594,7 @@ final class NativeMapView {
}
public PointF pixelForLatLng(LatLng latLng) {
- if (isDestroyedOn("pixelForLatLng")) {
+ if (checkState("pixelForLatLng")) {
return new PointF();
}
PointF pointF = nativePixelForLatLng(latLng.getLatitude(), latLng.getLongitude());
@@ -590,21 +603,21 @@ final class NativeMapView {
}
public LatLng latLngForPixel(PointF pixel) {
- if (isDestroyedOn("latLngForPixel")) {
+ if (checkState("latLngForPixel")) {
return new LatLng();
}
return nativeLatLngForPixel(pixel.x / pixelRatio, pixel.y / pixelRatio).wrap();
}
public double getTopOffsetPixelsForAnnotationSymbol(String symbolName) {
- if (isDestroyedOn("getTopOffsetPixelsForAnnotationSymbol")) {
+ if (checkState("getTopOffsetPixelsForAnnotationSymbol")) {
return 0;
}
return nativeGetTopOffsetPixelsForAnnotationSymbol(symbolName);
}
public void jumpTo(double angle, LatLng center, double pitch, double zoom) {
- if (isDestroyedOn("jumpTo")) {
+ if (checkState("jumpTo")) {
return;
}
nativeJumpTo(angle, center.getLatitude(), center.getLongitude(), pitch, zoom);
@@ -612,7 +625,7 @@ final class NativeMapView {
public void easeTo(double angle, LatLng center, long duration, double pitch, double zoom,
boolean easingInterpolator) {
- if (isDestroyedOn("easeTo")) {
+ if (checkState("easeTo")) {
return;
}
nativeEaseTo(angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom,
@@ -620,28 +633,28 @@ final class NativeMapView {
}
public void flyTo(double angle, LatLng center, long duration, double pitch, double zoom) {
- if (isDestroyedOn("flyTo")) {
+ if (checkState("flyTo")) {
return;
}
nativeFlyTo(angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom);
}
public CameraPosition getCameraPosition() {
- if (isDestroyedOn("getCameraValues")) {
+ if (checkState("getCameraValues")) {
return new CameraPosition.Builder().build();
}
return nativeGetCameraPosition();
}
public void setPrefetchesTiles(boolean enable) {
- if (isDestroyedOn("setPrefetchesTiles")) {
+ if (checkState("setPrefetchesTiles")) {
return;
}
nativeSetPrefetchesTiles(enable);
}
public boolean getPrefetchesTiles() {
- if (isDestroyedOn("getPrefetchesTiles")) {
+ if (checkState("getPrefetchesTiles")) {
return false;
}
return nativeGetPrefetchesTiles();
@@ -666,42 +679,42 @@ final class NativeMapView {
}
public List<Layer> getLayers() {
- if (isDestroyedOn("getLayers")) {
+ if (checkState("getLayers")) {
return null;
}
return Arrays.asList(nativeGetLayers());
}
public Layer getLayer(String layerId) {
- if (isDestroyedOn("getLayer")) {
+ if (checkState("getLayer")) {
return null;
}
return nativeGetLayer(layerId);
}
public void addLayer(@NonNull Layer layer) {
- if (isDestroyedOn("addLayer")) {
+ if (checkState("addLayer")) {
return;
}
nativeAddLayer(layer.getNativePtr(), null);
}
public void addLayerBelow(@NonNull Layer layer, @NonNull String below) {
- if (isDestroyedOn("addLayerBelow")) {
+ if (checkState("addLayerBelow")) {
return;
}
nativeAddLayer(layer.getNativePtr(), below);
}
public void addLayerAbove(@NonNull Layer layer, @NonNull String above) {
- if (isDestroyedOn("addLayerAbove")) {
+ if (checkState("addLayerAbove")) {
return;
}
nativeAddLayerAbove(layer.getNativePtr(), above);
}
public void addLayerAt(@NonNull Layer layer, @IntRange(from = 0) int index) {
- if (isDestroyedOn("addLayerAt")) {
+ if (checkState("addLayerAt")) {
return;
}
nativeAddLayerAt(layer.getNativePtr(), index);
@@ -709,7 +722,7 @@ final class NativeMapView {
@Nullable
public Layer removeLayer(@NonNull String layerId) {
- if (isDestroyedOn("removeLayer")) {
+ if (checkState("removeLayer")) {
return null;
}
return nativeRemoveLayerById(layerId);
@@ -717,7 +730,7 @@ final class NativeMapView {
@Nullable
public Layer removeLayer(@NonNull Layer layer) {
- if (isDestroyedOn("removeLayer")) {
+ if (checkState("removeLayer")) {
return null;
}
nativeRemoveLayer(layer.getNativePtr());
@@ -726,28 +739,28 @@ final class NativeMapView {
@Nullable
public Layer removeLayerAt(@IntRange(from = 0) int index) {
- if (isDestroyedOn("removeLayerAt")) {
+ if (checkState("removeLayerAt")) {
return null;
}
return nativeRemoveLayerAt(index);
}
public List<Source> getSources() {
- if (isDestroyedOn("getSources")) {
+ if (checkState("getSources")) {
return null;
}
return Arrays.asList(nativeGetSources());
}
public Source getSource(@NonNull String sourceId) {
- if (isDestroyedOn("getSource")) {
+ if (checkState("getSource")) {
return null;
}
return nativeGetSource(sourceId);
}
public void addSource(@NonNull Source source) {
- if (isDestroyedOn("addSource")) {
+ if (checkState("addSource")) {
return;
}
nativeAddSource(source, source.getNativePtr());
@@ -755,7 +768,7 @@ final class NativeMapView {
@Nullable
public Source removeSource(@NonNull String sourceId) {
- if (isDestroyedOn("removeSource")) {
+ if (checkState("removeSource")) {
return null;
}
Source source = getSource(sourceId);
@@ -767,7 +780,7 @@ final class NativeMapView {
@Nullable
public Source removeSource(@NonNull Source source) {
- if (isDestroyedOn("removeSource")) {
+ if (checkState("removeSource")) {
return null;
}
nativeRemoveSource(source, source.getNativePtr());
@@ -775,7 +788,7 @@ final class NativeMapView {
}
public void addImage(@NonNull String name, @NonNull Bitmap image) {
- if (isDestroyedOn("addImage")) {
+ if (checkState("addImage")) {
return;
}
@@ -785,7 +798,7 @@ final class NativeMapView {
}
public void addImages(@NonNull HashMap<String, Bitmap> bitmapHashMap) {
- if (isDestroyedOn("addImages")) {
+ if (checkState("addImages")) {
return;
}
//noinspection unchecked
@@ -793,14 +806,14 @@ final class NativeMapView {
}
public void removeImage(String name) {
- if (isDestroyedOn("removeImage")) {
+ if (checkState("removeImage")) {
return;
}
nativeRemoveImage(name);
}
public Bitmap getImage(String name) {
- if (isDestroyedOn("getImage")) {
+ if (checkState("getImage")) {
return null;
}
return nativeGetImage(name);
@@ -812,7 +825,7 @@ final class NativeMapView {
public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
@Nullable String[] layerIds,
@Nullable Expression filter) {
- if (isDestroyedOn("queryRenderedFeatures")) {
+ if (checkState("queryRenderedFeatures")) {
return new ArrayList<>();
}
Feature[] features = nativeQueryRenderedFeaturesForPoint(coordinates.x / pixelRatio,
@@ -824,7 +837,7 @@ final class NativeMapView {
public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
@Nullable String[] layerIds,
@Nullable Expression filter) {
- if (isDestroyedOn("queryRenderedFeatures")) {
+ if (checkState("queryRenderedFeatures")) {
return new ArrayList<>();
}
Feature[] features = nativeQueryRenderedFeaturesForBox(
@@ -838,14 +851,14 @@ final class NativeMapView {
}
public void setApiBaseUrl(String baseUrl) {
- if (isDestroyedOn("setApiBaseUrl")) {
+ if (checkState("setApiBaseUrl")) {
return;
}
fileSource.setApiBaseUrl(baseUrl);
}
public Light getLight() {
- if (isDestroyedOn("getLight")) {
+ if (checkState("getLight")) {
return null;
}
return nativeGetLight();
@@ -879,7 +892,7 @@ final class NativeMapView {
}
protected void onSnapshotReady(Bitmap mapContent) {
- if (isDestroyedOn("OnSnapshotReady")) {
+ if (checkState("OnSnapshotReady")) {
return;
}
@@ -1078,14 +1091,14 @@ final class NativeMapView {
private native boolean nativeGetPrefetchesTiles();
int getWidth() {
- if (isDestroyedOn("")) {
+ if (checkState("")) {
return 0;
}
return viewCallback.getWidth();
}
int getHeight() {
- if (isDestroyedOn("")) {
+ if (checkState("")) {
return 0;
}
return viewCallback.getHeight();
@@ -1110,7 +1123,7 @@ final class NativeMapView {
//
void addSnapshotCallback(@NonNull MapboxMap.SnapshotReadyCallback callback) {
- if (isDestroyedOn("addSnapshotCallback")) {
+ if (checkState("addSnapshotCallback")) {
return;
}
snapshotReadyCallback = callback;
@@ -1185,7 +1198,7 @@ final class NativeMapView {
@Override
protected void onPostExecute(List<Image> images) {
super.onPostExecute(images);
- if (nativeMapView != null && !nativeMapView.isDestroyedOn("nativeAddImages")) {
+ if (nativeMapView != null && !nativeMapView.checkState("nativeAddImages")) {
nativeMapView.nativeAddImages(images.toArray(new Image[images.size()]));
}
}