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

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

Introduction

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

Prototype

ReadableType getType();

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();//from  w w w . ja va  2 s.  co m
        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  w w  .ja va  2  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();
}