Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): support RN 0.77 #3749

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,12 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) :
Logger.e("RNMBXImages", "each element of strech should be an array but was: ${array.getDynamic(i)}")
} else {
val pair = array.getArray(i)
if (pair.size() != 2 || pair.getType(0) != ReadableType.Number || pair.getType(1) != ReadableType.Number) {
Logger.e("RNMBXImages", "each element of stretch should be pair of 2 integers but was ${pair}")
}
result.add(ImageStretches(pair.getDouble(0).toFloat(), pair.getDouble(1).toFloat()))
if (pair != null) {
if (pair.size() != 2 || pair.getType(0) != ReadableType.Number || pair.getType(1) != ReadableType.Number) {
Logger.e("RNMBXImages", "each element of stretch should be pair of 2 integers but was ${pair}")
}
result.add(ImageStretches(pair.getDouble(0).toFloat(), pair.getDouble(1).toFloat()))
}
}
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ import java.util.HashMap

fun ReadableArray.forEachString(action: (String) -> Unit) {
for (i in 0 until size()) {
action(getString(i))
getString(i)?.let { action(it) }
}
}

fun ReadableArray.asArrayString(): Array<String> {
val result = Array<String>(size()) {
getString(it)
getString(it).toString()
}
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class RNMBXStyleValue(config: ReadableMap) {
val result = ArrayList<Double>(arr!!.size())
for (i in 0 until arr.size()) {
val item = arr.getMap(i)
result.add(item.getDouble("value"))
if (item != null) {
result.add(item.getDouble("value"))
}
}
return result
}
Expand All @@ -104,7 +106,7 @@ class RNMBXStyleValue(config: ReadableMap) {
val result = ArrayList<String>(arr!!.size())
for (i in 0 until arr.size()) {
val item = arr.getMap(i)
val value = item.getString("value")
val value = item?.getString("value")
if (value != null) {
result.add(value)
} else {
Expand All @@ -121,17 +123,19 @@ class RNMBXStyleValue(config: ReadableMap) {
val result = WritableNativeMap()
for (i in 0 until keyValues!!.size()) {
val keyValue = keyValues.getArray(i)
val stringKey = keyValue.getMap(0).getString("value")
val stringKey = keyValue?.getMap(0)?.getString("value")
val value = WritableNativeMap()
value.merge(keyValue.getMap(1))
if (keyValue != null) {
keyValue.getMap(1)?.let { value.merge(it) }
}
result.putMap(stringKey!!, value)
}
return result
}
return null
}

fun getMap(_key: String?): ReadableMap? {
fun getMap(_key: String): ReadableMap? {
return map
}

Expand Down Expand Up @@ -227,4 +231,4 @@ class RNMBXStyleValue(config: ReadableMap) {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class RNMBXShapeSourceManager(private val mContext: ReactApplicationContext, val
)
ReadableType.Boolean -> Expression.literal(expressions.getBoolean(iExp))
ReadableType.Number -> Expression.literal(expressions.getDouble(iExp))
else -> Expression.literal(expressions.getString(iExp))
else -> expressions.getString(iExp)?.let { Expression.literal(it) }!!
}
builder.add(argument)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class RNMBXTileSourceManager<T : RNMBXTileSource<*>> internal construct
val urls: MutableList<String> = ArrayList()
for (i in 0 until tileUrlTemplates.asArray().size()) {
if (tileUrlTemplates.asArray().getType(0) == ReadableType.String) {
urls.add(tileUrlTemplates.asArray().getString(i))
tileUrlTemplates.asArray().getString(i)?.let { urls.add(it) }
}
}
source!!.tileUrlTemplates = urls
Expand All @@ -66,4 +66,4 @@ abstract class RNMBXTileSourceManager<T : RNMBXTileSource<*>> internal construct
fun setTms(source: T, tms: Dynamic) {
source!!.tMS = tms.asBoolean()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ private fun buildLineString(_coordinates: ReadableArray): LineString {

for (i in 0 until _coordinates.size()) {
val arr = _coordinates.getArray(i)
val coord = Point.fromLngLat(arr.getDouble(0), arr.getDouble(1))
val coord = Point.fromLngLat(arr!!.getDouble(0), arr.getDouble(1))
coordinates = coordinates.plus(coord)
}

return LineString.fromLngLats(coordinates)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ fun ReadableArray.toValue(): Value {
var result = ArrayList<Value>(size())

for (i in 0 until size()) {
result.add(
when (getType(i)) {
ReadableType.Null -> Value.nullValue()
ReadableType.Boolean -> Value.valueOf(getBoolean(i))
ReadableType.Number -> Value.valueOf(getDouble(i))
ReadableType.String -> Value.valueOf(getString(i))
ReadableType.Array -> getArray(i).toValue()
ReadableType.Map -> getMap(i).toValue()
})
ReadableType.String -> getString(i)?.let { Value.valueOf(it) }
ReadableType.Array -> getArray(i)?.toValue()
ReadableType.Map -> getMap(i)?.toValue()
}?.let {
result.add(it)
}
}
return Value.valueOf(result)
}
Expand Down Expand Up @@ -79,4 +80,4 @@ fun Dynamic.asStringOrNull(): String? {
} else {
asString()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ fun ReadableArray.toJsonArray() : JsonArray {
val result = JsonArray(size())
for (i in 0 until size()) {
when (getType(i)) {
ReadableType.Map -> result.add(getMap(i).toJsonObject())
ReadableType.Array -> result.add(getArray(i).toJsonArray())
ReadableType.Map -> result.add(getMap(i)!!.toJsonObject())
ReadableType.Array -> result.add(getArray(i)!!.toJsonArray())
ReadableType.Null -> result.add(null as JsonElement?)
ReadableType.Number -> result.add(getDouble(i))
ReadableType.String -> result.add(getString(i))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fun ReadableMap.forEach(action: (String, Any) -> Unit) {
val iterator = this.entryIterator
while (iterator.hasNext()) {
val next = iterator.next()
action(next.key, next.value)
next.value?.let { action(next.key, it) }
}
}
fun ReadableMap.getIfDouble(key: String): Double? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXAtmosphereManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXAtmosphereManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXAtmosphereManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXAtmosphereManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXAtmosphereManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXBackgroundLayerManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXBackgroundLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXBackgroundLayerManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXBackgroundLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXBackgroundLayerManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

import android.view.View;
import androidx.annotation.Nullable;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXCalloutManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXCalloutManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXCalloutManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXCalloutManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXCalloutManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXCameraManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXCameraManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXCameraManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXCameraManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXCameraManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXCircleLayerManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXCircleLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXCircleLayerManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXCircleLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXCircleLayerManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXCustomLocationProviderManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXCustomLocationProviderManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXCustomLocationProviderManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXCustomLocationProviderManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXCustomLocationProviderManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXFillExtrusionLayerManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXFillExtrusionLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXFillExtrusionLayerManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXFillExtrusionLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXFillExtrusionLayerManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXFillLayerManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXFillLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXFillLayerManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXFillLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXFillLayerManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXHeatmapLayerManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXHeatmapLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXHeatmapLayerManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXHeatmapLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXHeatmapLayerManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXImageManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXImageManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXImageManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXImageManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXImageManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXImageSourceManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXImageSourceManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXImageSourceManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXImageSourceManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXImageSourceManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXImagesManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXImagesManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXImagesManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXImagesManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXImagesManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXLightManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXLightManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXLightManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXLightManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXLightManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXLineLayerManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXLineLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXLineLayerManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXLineLayerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXLineLayerManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;

import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNMBXMapViewManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXMapViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class RNMBXMapViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNMBXMapViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXMapViewManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down
Loading