diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterSourceManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterSourceManager.kt index 01925dca4..17807bf84 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterSourceManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterSourceManager.kt @@ -8,9 +8,7 @@ import com.facebook.react.viewmanagers.RNMBXRasterSourceManagerInterface import com.rnmapbox.rnmbx.events.constants.EventKeys import com.rnmapbox.rnmbx.events.constants.eventMapOf import javax.annotation.Nonnull -import com.facebook.react.bridge.ReadableArray -import com.rnmapbox.rnmbx.components.styles.RNMBXStyleImportManager -import com.rnmapbox.rnmbx.components.styles.RNMBXStyleImportManager.Companion +import com.facebook.react.bridge.ReadableType import com.rnmapbox.rnmbx.utils.Logger class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext) : @@ -49,25 +47,21 @@ class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext) @ReactProp(name = "sourceBounds") override fun setSourceBounds(source: RNMBXRasterSource, value: Dynamic) { - if (value.type.name == "Array") { - val readableArray: ReadableArray = value.asArray() - - if (readableArray.size() == 4) { - val bboxArray = Array(4) { i -> readableArray.getDouble(i) } - - if(this.validateBbox(bboxArray)){ - source.setSourceBounds(bboxArray) - } else { - Logger.e(RNMBXRasterSourceManager.REACT_CLASS, "source bounds contain invalid bbox") - } + if (value.type != ReadableType.Array || value.asArray().size() != 4) { + Logger.e(REACT_CLASS, "source bounds must be an array with left, bottom, top, and right values") + return + } + val bboxArray = Array(4) { i -> value.asArray().getDouble(i) } - return - } + if(!this.validateBbox(bboxArray)){ + Logger.e(REACT_CLASS, "source bounds contain invalid bbox") + return } - Logger.e(RNMBXRasterSourceManager.REACT_CLASS, "source bounds must be an array with left, bottom, top, and right values") + + source.setSourceBounds(bboxArray) } - fun validateBbox(bbox: Array): Boolean { + private fun validateBbox(bbox: Array): Boolean { if (bbox.size != 4) return false val (swLng, swLat, neLng, neLat) = bbox diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSource.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSource.kt index b5c768e3f..84dd9f381 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSource.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSource.kt @@ -36,9 +36,8 @@ abstract class RNMBXTileSource(context: Context?) : RNMBXSource( if (attribution != null) { builder.attribution(attribution) } - if(bounds != null) { - val boundsArray = bounds!!.clone() - builder.bounds(Arrays.asList(*boundsArray)) + bounds?.let { + builder.bounds(it.toList()) } return builder.build() }