Example usage for com.facebook.react.bridge Dynamic asArray

List of usage examples for com.facebook.react.bridge Dynamic asArray

Introduction

In this page you can find the example usage for com.facebook.react.bridge Dynamic asArray.

Prototype

ReadableArray asArray();

Source Link

Usage

From source file:com.horcrux.svg.RenderableView.java

License:Open Source License

@ReactProp(name = "fill")
public void setFill(@Nullable Dynamic fill) {
    if (fill == null || fill.isNull()) {
        this.fill = null;
        invalidate();/*  ww w  .  java 2 s . c  om*/
        return;
    }
    ReadableType type = fill.getType();
    if (type.equals(ReadableType.Array)) {
        this.fill = fill.asArray();
    } else {
        JavaOnlyArray arr = new JavaOnlyArray();
        arr.pushInt(0);
        Matcher m = regex.matcher(fill.asString());
        int i = 0;
        while (m.find()) {
            Double parsed = Double.parseDouble(m.group());
            arr.pushDouble(i++ < 3 ? parsed / 255 : parsed);
        }
        this.fill = arr;
    }
    invalidate();
}

From source file:com.horcrux.svg.RenderableView.java

License:Open Source License

@ReactProp(name = "stroke")
public void setStroke(@Nullable Dynamic strokeColors) {
    if (strokeColors == null || strokeColors.isNull()) {
        stroke = null;//from w  ww  .ja v a2 s.  c o  m
        invalidate();
        return;
    }
    ReadableType type = strokeColors.getType();
    if (type.equals(ReadableType.Array)) {
        stroke = strokeColors.asArray();
    } else {
        JavaOnlyArray arr = new JavaOnlyArray();
        arr.pushInt(0);
        Matcher m = regex.matcher(strokeColors.asString());
        while (m.find()) {
            Double parsed = Double.parseDouble(m.group());
            arr.pushDouble(parsed);
        }
        stroke = arr;
    }
    invalidate();
}