diff --git a/android/build.gradle b/android/build.gradle index a008e17d7..8974ba232 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -31,7 +31,11 @@ buildscript { mavenCentral() } - project.ext.set("kotlinVersion", rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : '1.7.21') + ext { + rnmapboxDefaultKotlinVersion = '1.7.21' + } + + project.ext.set("kotlinVersion", rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : rnmapboxDefaultKotlinVersion) dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${project.kotlinVersion}" } diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/AbstractEventEmitter.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/AbstractEventEmitter.kt index d46bf9a18..e51687fb9 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/AbstractEventEmitter.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/AbstractEventEmitter.kt @@ -15,7 +15,7 @@ import com.rnmapbox.rnmbx.utils.Logger /** * Created by nickitaliano on 8/23/17. */ -abstract class AbstractEventEmitter(reactApplicationContext: ReactApplicationContext) : +abstract class AbstractEventEmitter(reactApplicationContext: ReactApplicationContext) : ViewGroupManager() { private val mRateLimitedEvents: MutableMap private var mEventDispatcher: EventDispatcher? = null @@ -56,8 +56,8 @@ abstract class AbstractEventEmitter(reactApplicationContext: Rea } } - override fun addEventEmitters(context: ThemedReactContext, view: T & Any) { - mEventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, view!!.id) + override fun addEventEmitters(context: ThemedReactContext, view: T) { + mEventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(context, view.id) } override fun getExportedCustomDirectEventTypeConstants(): Map? { diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXPointAnnotationManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXPointAnnotationManager.kt index 9808eb227..4920db6ac 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXPointAnnotationManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXPointAnnotationManager.kt @@ -43,7 +43,7 @@ class RNMBXPointAnnotationManager(reactApplicationContext: ReactApplicationConte } override fun createViewInstance(reactContext: ThemedReactContext): RNMBXPointAnnotation { - return RNMBXPointAnnotation(reactContext!!, this) + return RNMBXPointAnnotation(reactContext, this) } override fun onDropViewInstance(view: RNMBXPointAnnotation) { diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt index 9523702b7..106c020a6 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt @@ -16,7 +16,7 @@ import com.rnmapbox.rnmbx.utils.extensions.asStringOrNull import com.rnmapbox.rnmbx.rncompat.dynamic.* class RNMBXCameraManager(private val mContext: ReactApplicationContext, val viewTagResolver: ViewTagResolver) : - AbstractEventEmitter( + AbstractEventEmitter( mContext ), RNMBXCameraManagerInterface { override fun customEvents(): Map? { diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXVIewportManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXVIewportManager.kt index 4460eab7a..12511fd74 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXVIewportManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXVIewportManager.kt @@ -14,7 +14,7 @@ import com.rnmapbox.rnmbx.events.constants.EventKeys import com.rnmapbox.rnmbx.events.constants.eventMapOf import com.rnmapbox.rnmbx.utils.ViewTagResolver -class RNMBXViewportManager(private val mContext: ReactApplicationContext, val viewTagResolver: ViewTagResolver) : AbstractEventEmitter( +class RNMBXViewportManager(private val mContext: ReactApplicationContext, val viewTagResolver: ViewTagResolver) : AbstractEventEmitter( mContext ), RNMBXViewportManagerInterface { diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt index a9e2b683c..fb2147f94 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt @@ -24,7 +24,7 @@ import com.rnmapbox.rnmbx.utils.extensions.getIfDouble import java.util.* class RNMBXImagesManager(private val mContext: ReactApplicationContext) : - AbstractEventEmitter( + AbstractEventEmitter( mContext ), RNMBXImagesManagerInterface { override fun getName(): String { @@ -53,7 +53,7 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) : stretchY = convertStretch(map.getDynamic("stretchY")) ?: listOf() } if (map.hasKey("content")) { - content = convertContent(map.getDynamic("content")) ?: null + content = convertContent(map.getDynamic("content")) } if (map.hasKey("scale")) { if (map.getType("scale") != ReadableType.Number) { @@ -210,11 +210,6 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) : // region RNMBXImage children override fun addView(parent: RNMBXImages, childView: View, childPosition: Int) { - if (parent == null || childView == null) { - Logger.e("RNMBXImages", "addView: parent or childView is null") - return - } - if (childView !is RNMBXImage) { Logger.e("RNMBXImages", "child view should be RNMBXImage") return @@ -234,11 +229,6 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) : } override fun removeAllViews(parent: RNMBXImages) { - if (parent == null) { - Logger.e("RNMBXImages", "removeAllViews parent is null") - return - } - parent.mImageViews.clear() } diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt index 860128694..220cf5448 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt @@ -87,19 +87,19 @@ open class RNMBXMapViewManager(context: ReactApplicationContext, val viewTagReso } override fun addView(mapView: RNMBXMapView, childView: View, childPosition: Int) { - mapView!!.addFeature(childView, childPosition) + mapView.addFeature(childView, childPosition) } override fun getChildCount(mapView: RNMBXMapView): Int { - return mapView!!.featureCount + return mapView.featureCount } override fun getChildAt(mapView: RNMBXMapView, index: Int): View? { - return mapView!!.getFeatureAt(index) + return mapView.getFeatureAt(index) } override fun removeViewAt(mapView: RNMBXMapView, index: Int) { - mapView!!.removeFeatureAt(index) + mapView.removeFeatureAt(index) } fun getMapViewContext(themedReactContext: ThemedReactContext): Context { @@ -140,7 +140,7 @@ open class RNMBXMapViewManager(context: ReactApplicationContext, val viewTagReso @ReactProp(name = "localizeLabels") override fun setLocalizeLabels(mapView: RNMBXMapView, localeMap: Dynamic) { val locale = localeMap.asMap().getString("locale") - val layerIds = localeMap.asMap().getArray("layerIds")?.toArrayList()?.mapNotNull {it?.toString()} + val layerIds = localeMap.asMap().getArray("layerIds")?.toArrayList()?.mapNotNull {it.toString()} mapView.setReactLocalizeLabels(locale, layerIds) } @@ -210,8 +210,8 @@ open class RNMBXMapViewManager(context: ReactApplicationContext, val viewTagReso mapView.setReactStyleURL(styleURL.asString()) } - @ReactProp(name = "preferredFramesPerSecond") - fun setPreferredFramesPerSecond(mapView: RNMBXMapView?, preferredFramesPerSecond: Int) { + @ReactProp(name = "preferredFramesPerSecond") @Suppress("UNUSED_PARAMETER") + fun setPreferredFramesPerSecond(mapView: RNMBXMapView, preferredFramesPerSecond: Int) { //mapView.setReactPreferredFramesPerSecond(preferredFramesPerSecond); } @@ -302,7 +302,7 @@ open class RNMBXMapViewManager(context: ReactApplicationContext, val viewTagReso @ReactProp(name = "compassViewMargins") override fun setCompassViewMargins(mapView: RNMBXMapView, compassViewMargins: Dynamic) { - mapView.setReactCompassViewMargins(compassViewMargins.asMap() ?: return) + mapView.setReactCompassViewMargins(compassViewMargins.asMap()) } @ReactProp(name = "compassViewPosition") @@ -315,13 +315,13 @@ open class RNMBXMapViewManager(context: ReactApplicationContext, val viewTagReso mapView.setReactCompassPosition(compassMargins.asMap()) } - @ReactProp(name = "contentInset") + @ReactProp(name = "contentInset") @Suppress("UNUSED_PARAMETER") fun setContentInset(mapView: RNMBXMapView, array: ReadableArray) { // remember to add it to codegen if it will be used //mapView.setReactContentInset(array); } - @ReactProp(name = "tintColor", customType = "Color") + @ReactProp(name = "tintColor", customType = "Color") @Suppress("UNUSED_PARAMETER") fun setTintColor(mapView: RNMBXMapView, tintColor: Int) { // remember to add it to codegen if it will be used //mapView.setTintColor(tintColor); diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSourceManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSourceManager.kt index c843d11f0..6486d2089 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSourceManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterDemSourceManager.kt @@ -11,7 +11,7 @@ import com.rnmapbox.rnmbx.utils.Logger // import com.rnmapbox.rnmbx.components.annotation.RNMBXCallout; // import com.rnmapbox.rnmbx.utils.ResourceUtils; class RNMBXRasterDemSourceManager(private val mContext: ReactApplicationContext) : - RNMBXTileSourceManager( + RNMBXTileSourceManager( mContext ), RNMBXRasterDemSourceManagerInterface { override fun customEvents(): Map? { 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 5bebc1b30..893d757c0 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,7 +8,7 @@ import com.facebook.react.viewmanagers.RNMBXRasterSourceManagerInterface import javax.annotation.Nonnull class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext) : - RNMBXTileSourceManager(reactApplicationContext), + RNMBXTileSourceManager(reactApplicationContext), RNMBXRasterSourceManagerInterface { @Nonnull override fun getName(): String { diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt index e18cbcfc0..3b0a072f3 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt @@ -7,33 +7,33 @@ import com.facebook.react.bridge.ReadableType import com.facebook.react.uimanager.annotations.ReactProp import com.rnmapbox.rnmbx.components.AbstractEventEmitter -abstract class RNMBXTileSourceManager?> internal constructor( +abstract class RNMBXTileSourceManager> internal constructor( reactApplicationContext: ReactApplicationContext ) : AbstractEventEmitter(reactApplicationContext) { - override fun getChildAt(source: T & Any, childPosition: Int): View { - return source!!.getChildAt(childPosition) + override fun getChildAt(source: T, childPosition: Int): View { + return source.getChildAt(childPosition) } - override fun getChildCount(source: T & Any): Int { - return source!!.childCount + override fun getChildCount(source: T): Int { + return source.childCount } - override fun addView(source: T & Any, childView: View, childPosition: Int) { - source!!.addLayer(childView, childPosition) + override fun addView(source: T, childView: View, childPosition: Int) { + source.addLayer(childView, childPosition) } - override fun removeViewAt(source: T & Any, childPosition: Int) { - source!!.removeLayer(childPosition) + override fun removeViewAt(source: T, childPosition: Int) { + source.removeLayer(childPosition) } @ReactProp(name = "id") fun setId(source: T, id: Dynamic) { - source!!.iD = id.asString() + source.iD = id.asString() } @ReactProp(name = "url") fun setUrl(source: T, url: Dynamic) { - source!!.uRL = url.asString() + source.uRL = url.asString() } @ReactProp(name = "tileUrlTemplates") diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXVectorSourceManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXVectorSourceManager.kt index 63b1cfbfd..b0d3e88b2 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXVectorSourceManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXVectorSourceManager.kt @@ -11,7 +11,7 @@ import com.rnmapbox.rnmbx.events.constants.eventMapOf import javax.annotation.Nonnull class RNMBXVectorSourceManager(reactApplicationContext: ReactApplicationContext) : - RNMBXTileSourceManager(reactApplicationContext), + RNMBXTileSourceManager(reactApplicationContext), RNMBXVectorSourceManagerInterface { @Nonnull override fun getName(): String {