Example usage for com.facebook.react.bridge ReadableType Array

List of usage examples for com.facebook.react.bridge ReadableType Array

Introduction

In this page you can find the example usage for com.facebook.react.bridge ReadableType Array.

Prototype

ReadableType Array

To view the source code for com.facebook.react.bridge ReadableType Array.

Click 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();//  w w w . j  a v a2  s.  com
        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;// w  ww  .  j a  va2 s  .  co 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();
}