Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 58430f7

Browse files
authored
[style] add image array support (#544)
1 parent 02e253f commit 58430f7

File tree

2 files changed

+28
-2
lines changed
  • MapboxGLAndroidSDK/src

2 files changed

+28
-2
lines changed

MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ public void addImageAsync(@NonNull String name, @NonNull Drawable drawable) {
438438
addImageAsync(name, bitmap, false);
439439
}
440440

441-
442441
/**
443442
* Adds an drawable asynchronously, to be converted into a bitmap to be used in the map's style.
444443
*
@@ -606,6 +605,16 @@ public void addImagesAsync(@NonNull HashMap<String, Bitmap> images, boolean sdf,
606605
.execute(Builder.ImageWrapper.convertToImageArray(images, sdf, stretchX, stretchY, content));
607606
}
608607

608+
/**
609+
* Add images synchronously, to be used in the map's style.
610+
*
611+
* @param images the array of images to add
612+
*/
613+
public void addImages(Image[] images) {
614+
validateState("addImages");
615+
nativeMap.addImages(images);
616+
}
617+
609618
/**
610619
* Removes an image from the map's style.
611620
*
@@ -1425,7 +1434,7 @@ public interface OnStyleLoaded {
14251434
* constants means your map style will always use the latest version and may change as we
14261435
* improve the style
14271436
*/
1428-
@StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT})
1437+
@StringDef({MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT})
14291438
@Retention(RetentionPolicy.SOURCE)
14301439
public @interface StyleUrl {
14311440
}

MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,21 @@ class StyleTest {
405405
Assert.assertEquals("Layer that failed to be added shouldn't be cached", layer1, mapboxMap.style!!.getLayer("layer1"))
406406
}
407407
}
408+
409+
@Test
410+
fun addImages() {
411+
val images = arrayOf(mockk<Image>())
412+
mapboxMap.setStyle(Style.Builder())
413+
mapboxMap.notifyStyleLoaded()
414+
val style = mapboxMap.style!!
415+
style.addImages(images)
416+
verify { nativeMapView.addImages(images) }
417+
}
418+
419+
@Test(expected = IllegalStateException::class)
420+
fun addImagesNotLoadedStyleThrows() {
421+
val images = arrayOf(mockk<Image>())
422+
val style = Style.Builder().build(mockk())
423+
style.addImages(images)
424+
}
408425
}

0 commit comments

Comments
 (0)