use of com.facebook.react.bridge.JavaOnlyArray in project react-native-svg by react-native-svg.
the class RenderableView method setStroke.
@ReactProp(name = "stroke")
public void setStroke(@Nullable Dynamic strokeColors) {
if (strokeColors == null || strokeColors.isNull()) {
stroke = null;
invalidate();
return;
}
ReadableType type = strokeColors.getType();
if (type.equals(ReadableType.Number)) {
stroke = JavaOnlyArray.of(0, strokeColors.asInt());
} else if (type.equals(ReadableType.Array)) {
stroke = strokeColors.asArray();
} else {
JavaOnlyArray arr = new JavaOnlyArray();
arr.pushInt(0);
Matcher m = regex.matcher(strokeColors.asString());
int i = 0;
while (m.find()) {
double parsed = Double.parseDouble(m.group());
arr.pushDouble(i++ < 3 ? parsed / 255 : parsed);
}
stroke = arr;
}
invalidate();
}
Aggregations