Example usage for com.facebook.react.bridge JavaOnlyArray JavaOnlyArray

List of usage examples for com.facebook.react.bridge JavaOnlyArray JavaOnlyArray

Introduction

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

Prototype

public JavaOnlyArray() 

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  ww.  ja v  a 2  s  . c o  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;//ww  w.  ja  va2s .  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();
}

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

License:Open Source License

@Override
protected void saveDefinition() {
    if (mName != null) {
        WritableArray points = new JavaOnlyArray();
        points.pushString(mX1);//from   w w w.ja  v  a 2  s .  c  o  m
        points.pushString(mY1);
        points.pushString(mX2);
        points.pushString(mY2);

        PropHelper.RNSVGBrush brush = new PropHelper.RNSVGBrush(
                PropHelper.RNSVGBrush.GradientType.LINEAR_GRADIENT, points, mGradient);
        getSvgShadowNode().defineBrush(brush, mName);
    }
}

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

License:Open Source License

@Override
protected void saveDefinition() {
    if (mName != null) {
        WritableArray points = new JavaOnlyArray();
        points.pushString(mFx);//from w  w  w . ja v  a  2 s  .  c  om
        points.pushString(mFy);
        points.pushString(mRx);
        points.pushString(mRy);
        points.pushString(mCx);
        points.pushString(mCy);

        PropHelper.RNSVGBrush brush = new PropHelper.RNSVGBrush(
                PropHelper.RNSVGBrush.GradientType.RADIAL_GRADIENT, points, mGradient);
        getSvgShadowNode().defineBrush(brush, mName);
    }
}

From source file:versioned.host.exp.exponent.modules.api.components.svg.RNSVGPathShadowNode.java

License:Open Source License

@ReactProp(name = "propList")
public void setPropList(@Nullable ReadableArray propList) {
    WritableArray copy = new JavaOnlyArray();

    if (propList != null) {
        for (int i = 0; i < propList.size(); i++) {
            copy.pushString(propertyNameToFieldName(propList.getString(i)));
        }//from w ww. j  ava 2  s.  com
    }

    mPropList = copy;
    markUpdated();
}

From source file:versioned.host.exp.exponent.modules.api.components.svg.RNSVGPathShadowNode.java

License:Open Source License

@Override
public void mergeProperties(RNSVGVirtualNode target, ReadableArray mergeList, boolean inherited) {
    if (mergeList.size() == 0) {
        return;//from   www .  ja  v  a 2 s. c  o m
    }

    if (!inherited) {
        mOriginProperties = new ArrayList<>();
        mChangedList = new ArrayList<>();
    }

    WritableArray propList = new JavaOnlyArray();
    for (int i = 0; i < mPropList.size(); i++) {
        propList.pushString(mPropList.getString(i));
    }

    for (int i = 0, size = mergeList.size(); i < size; i++) {
        try {
            String fieldName = mergeList.getString(i);
            Field field = getClass().getField(fieldName);
            Object value = field.get(target);

            if (inherited) {
                if (!hasOwnProperty(fieldName)) {
                    field.set(this, value);
                    propList.pushString(fieldName);
                }
            } else {
                mOriginProperties.add(field.get(this));
                mChangedList.add(fieldName);
                field.set(this, value);
            }
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }

    if (inherited) {
        mPropList = propList;
    }

}