diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com')
2 files changed, 36 insertions, 46 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 58fc66407f..7cc1d003df 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -351,13 +351,12 @@ public final class MapboxMap { } /** - * Removes the layer. Any references to the layer become invalid and should not be used anymore + * Removes the layer. The reference is re-usable after this and can be re-added * * @param layerId the layer to remove - * @return the removed layer or null if not found + * @return true if the layer was successfully removed, false - otherwise */ - @Nullable - public Layer removeLayer(@NonNull String layerId) { + public boolean removeLayer(@NonNull String layerId) { return nativeMapView.removeLayer(layerId); } @@ -365,10 +364,9 @@ public final class MapboxMap { * Removes the layer. The reference is re-usable after this and can be re-added * * @param layer the layer to remove - * @return the layer + * @return true if the layer was successfully removed, false - otherwise */ - @Nullable - public Layer removeLayer(@NonNull Layer layer) { + public boolean removeLayer(@NonNull Layer layer) { return nativeMapView.removeLayer(layer); } @@ -376,10 +374,9 @@ public final class MapboxMap { * Removes the layer. Any other references to the layer become invalid and should not be used anymore * * @param index the layer index - * @return the removed layer or null if not found + * @return true if the layer was successfully removed, false - otherwise */ - @Nullable - public Layer removeLayerAt(@IntRange(from = 0) int index) { + public boolean removeLayerAt(@IntRange(from = 0) int index) { return nativeMapView.removeLayerAt(index); } @@ -434,13 +431,12 @@ public final class MapboxMap { } /** - * Removes the source. Any references to the source become invalid and should not be used anymore + * Removes the source, preserving the reference for re-use * * @param sourceId the source to remove - * @return the source handle or null if the source was not present + * @return true if the source was successfully removed, false - otherwise */ - @Nullable - public Source removeSource(@NonNull String sourceId) { + public boolean removeSource(@NonNull String sourceId) { return nativeMapView.removeSource(sourceId); } @@ -448,10 +444,9 @@ public final class MapboxMap { * Removes the source, preserving the reference for re-use * * @param source the source to remove - * @return the source + * @return true if the source was successfully removed, false - otherwise */ - @Nullable - public Source removeSource(@NonNull Source source) { + public boolean removeSource(@NonNull Source source) { return nativeMapView.removeSource(source); } 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 532f311e90..035aa0361b 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 @@ -748,29 +748,32 @@ final class NativeMapView { nativeAddLayerAt(layer.getNativePtr(), index); } - @Nullable - public Layer removeLayer(@NonNull String layerId) { + public boolean removeLayer(@NonNull String layerId) { if (checkState("removeLayer")) { - return null; + return false; } - return nativeRemoveLayerById(layerId); + + Layer layer = getLayer(layerId); + if (layer != null) { + return removeLayer(layer); + } + return false; } - @Nullable - public Layer removeLayer(@NonNull Layer layer) { + + public boolean removeLayer(@NonNull Layer layer) { if (checkState("removeLayer")) { - return null; + return false; } - nativeRemoveLayer(layer.getNativePtr()); - return layer; + return nativeRemoveLayer(layer.getNativePtr()); } - @Nullable - public Layer removeLayerAt(@IntRange(from = 0) int index) { + public boolean removeLayerAt(@IntRange(from = 0) int index) { if (checkState("removeLayerAt")) { - return null; + return false; } return nativeRemoveLayerAt(index); + } public List<Source> getSources() { @@ -794,25 +797,22 @@ final class NativeMapView { nativeAddSource(source, source.getNativePtr()); } - @Nullable - public Source removeSource(@NonNull String sourceId) { + public boolean removeSource(@NonNull String sourceId) { if (checkState("removeSource")) { - return null; + return false; } Source source = getSource(sourceId); if (source != null) { return removeSource(source); } - return null; + return false; } - @Nullable - public Source removeSource(@NonNull Source source) { + public boolean removeSource(@NonNull Source source) { if (checkState("removeSource")) { - return null; + return false; } - nativeRemoveSource(source, source.getNativePtr()); - return source; + return nativeRemoveSource(source, source.getNativePtr()); } public void addImage(@NonNull String name, @NonNull Bitmap image, boolean sdf) { @@ -1217,16 +1217,11 @@ final class NativeMapView { @Keep private native void nativeAddLayerAt(long layerPtr, int index) throws CannotAddLayerException; - @NonNull @Keep - private native Layer nativeRemoveLayerById(String layerId); + private native boolean nativeRemoveLayer(long layerId); @Keep - private native void nativeRemoveLayer(long layerId); - - @NonNull - @Keep - private native Layer nativeRemoveLayerAt(int index); + private native boolean nativeRemoveLayerAt(int index); @NonNull @Keep @@ -1240,7 +1235,7 @@ final class NativeMapView { private native void nativeAddSource(Source source, long sourcePtr) throws CannotAddSourceException; @Keep - private native void nativeRemoveSource(Source source, long sourcePtr); + private native boolean nativeRemoveSource(Source source, long sourcePtr); @Keep private native void nativeAddImage(String name, Bitmap bitmap, float pixelRatio, boolean sdf); |