Skip to content

Commit

Permalink
fix(android): android build on pre 0.75 (#3604)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfazekas authored Sep 1, 2024
1 parent b96cdb9 commit fef7157
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 43 deletions.
6 changes: 5 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.rnmapbox.rnmbx.utils.Logger
/**
* Created by nickitaliano on 8/23/17.
*/
abstract class AbstractEventEmitter<T : ViewGroup?>(reactApplicationContext: ReactApplicationContext) :
abstract class AbstractEventEmitter<T : ViewGroup>(reactApplicationContext: ReactApplicationContext) :
ViewGroupManager<T>() {
private val mRateLimitedEvents: MutableMap<String, Long>
private var mEventDispatcher: EventDispatcher? = null
Expand Down Expand Up @@ -56,8 +56,8 @@ abstract class AbstractEventEmitter<T : ViewGroup?>(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<String, Any>? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RNMBXCamera?>(
AbstractEventEmitter<RNMBXCamera>(
mContext
), RNMBXCameraManagerInterface<RNMBXCamera> {
override fun customEvents(): Map<String, String>? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RNMBXViewport?>(
class RNMBXViewportManager(private val mContext: ReactApplicationContext, val viewTagResolver: ViewTagResolver) : AbstractEventEmitter<RNMBXViewport>(
mContext
), RNMBXViewportManagerInterface<RNMBXViewport> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.rnmapbox.rnmbx.utils.extensions.getIfDouble
import java.util.*

class RNMBXImagesManager(private val mContext: ReactApplicationContext) :
AbstractEventEmitter<RNMBXImages?>(
AbstractEventEmitter<RNMBXImages>(
mContext
), RNMBXImagesManagerInterface<RNMBXImages> {
override fun getName(): String {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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")
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RNMBXRasterDemSource?>(
RNMBXTileSourceManager<RNMBXRasterDemSource>(
mContext
), RNMBXRasterDemSourceManagerInterface<RNMBXRasterDemSource> {
override fun customEvents(): Map<String, String>? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.facebook.react.viewmanagers.RNMBXRasterSourceManagerInterface
import javax.annotation.Nonnull

class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext) :
RNMBXTileSourceManager<RNMBXRasterSource?>(reactApplicationContext),
RNMBXTileSourceManager<RNMBXRasterSource>(reactApplicationContext),
RNMBXRasterSourceManagerInterface<RNMBXRasterSource> {
@Nonnull
override fun getName(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T : RNMBXTileSource<*>?> internal constructor(
abstract class RNMBXTileSourceManager<T : RNMBXTileSource<*>> internal constructor(
reactApplicationContext: ReactApplicationContext
) : AbstractEventEmitter<T>(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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.rnmapbox.rnmbx.events.constants.eventMapOf
import javax.annotation.Nonnull

class RNMBXVectorSourceManager(reactApplicationContext: ReactApplicationContext) :
RNMBXTileSourceManager<RNMBXVectorSource?>(reactApplicationContext),
RNMBXTileSourceManager<RNMBXVectorSource>(reactApplicationContext),
RNMBXVectorSourceManagerInterface<RNMBXVectorSource> {
@Nonnull
override fun getName(): String {
Expand Down

0 comments on commit fef7157

Please sign in to comment.