Java Code Examples for com.facebook.react.bridge.Dynamic

The following are top voted examples for showing how to use com.facebook.react.bridge.Dynamic. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
void setFromDynamic(Dynamic dynamic) {
  if (dynamic.isNull()) {
    unit = YogaUnit.UNDEFINED;
    value = YogaConstants.UNDEFINED;
  } else if (dynamic.getType() == ReadableType.String) {
    final String s = dynamic.asString();
    if (s.equals("auto")) {
      unit = YogaUnit.AUTO;
      value = YogaConstants.UNDEFINED;
    } else if (s.endsWith("%")) {
      unit = YogaUnit.PERCENT;
      value = Float.parseFloat(s.substring(0, s.length() - 1));
    } else {
      throw new IllegalArgumentException("Unknown value: " + s);
    }
  } else {
    unit = YogaUnit.POINT;
    value = PixelUtil.toPixelFromDIP(dynamic.asDouble());
  }
}
 
Example 2
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.WIDTH)
public void setWidth(Dynamic width) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(width);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleWidth(mTempYogaValue.value);
      break;
    case AUTO:
      setStyleWidthAuto();
      break;
    case PERCENT:
      setStyleWidthPercent(mTempYogaValue.value);
      break;
  }

  width.recycle();
}
 
Example 3
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.MIN_WIDTH)
public void setMinWidth(Dynamic minWidth) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(minWidth);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleMinWidth(mTempYogaValue.value);
      break;
    case PERCENT:
      setStyleMinWidthPercent(mTempYogaValue.value);
      break;
  }

  minWidth.recycle();
}
 
Example 4
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.MAX_WIDTH)
public void setMaxWidth(Dynamic maxWidth) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(maxWidth);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleMaxWidth(mTempYogaValue.value);
      break;
    case PERCENT:
      setStyleMaxWidthPercent(mTempYogaValue.value);
      break;
  }

  maxWidth.recycle();
}
 
Example 5
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.HEIGHT)
public void setHeight(Dynamic height) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(height);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleHeight(mTempYogaValue.value);
      break;
    case AUTO:
      setStyleHeightAuto();
      break;
    case PERCENT:
      setStyleHeightPercent(mTempYogaValue.value);
      break;
  }

  height.recycle();
}
 
Example 6
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.MIN_HEIGHT)
public void setMinHeight(Dynamic minHeight) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(minHeight);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleMinHeight(mTempYogaValue.value);
      break;
    case PERCENT:
      setStyleMinHeightPercent(mTempYogaValue.value);
      break;
  }

  minHeight.recycle();
}
 
Example 7
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.MAX_HEIGHT)
public void setMaxHeight(Dynamic maxHeight) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(maxHeight);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleMaxHeight(mTempYogaValue.value);
      break;
    case PERCENT:
      setStyleMaxHeightPercent(mTempYogaValue.value);
      break;
  }

  maxHeight.recycle();
}
 
Example 8
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.FLEX_BASIS)
public void setFlexBasis(Dynamic flexBasis) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(flexBasis);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setFlexBasis(mTempYogaValue.value);
      break;
    case AUTO:
      setFlexBasisAuto();
      break;
    case PERCENT:
      setFlexBasisPercent(mTempYogaValue.value);
      break;
  }

  flexBasis.recycle();
}
 
Example 9
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactPropGroup(names = {
    ViewProps.LEFT,
    ViewProps.RIGHT,
    ViewProps.TOP,
    ViewProps.BOTTOM,
})
public void setPositionValues(int index, Dynamic position) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(position);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setPosition(ViewProps.POSITION_SPACING_TYPES[index], mTempYogaValue.value);
      break;
    case PERCENT:
      setPositionPercent(ViewProps.POSITION_SPACING_TYPES[index], mTempYogaValue.value);
      break;
  }

  position.recycle();
}
 
Example 10
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
void setFromDynamic(Dynamic dynamic) {
  if (dynamic.isNull()) {
    unit = YogaUnit.UNDEFINED;
    value = YogaConstants.UNDEFINED;
  } else if (dynamic.getType() == ReadableType.String) {
    final String s = dynamic.asString();
    if (s.equals("auto")) {
      unit = YogaUnit.AUTO;
      value = YogaConstants.UNDEFINED;
    } else if (s.endsWith("%")) {
      unit = YogaUnit.PERCENT;
      value = Float.parseFloat(s.substring(0, s.length() - 1));
    } else {
      throw new IllegalArgumentException("Unknown value: " + s);
    }
  } else {
    unit = YogaUnit.POINT;
    value = PixelUtil.toPixelFromDIP(dynamic.asDouble());
  }
}
 
Example 11
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.WIDTH)
public void setWidth(Dynamic width) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(width);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleWidth(mTempYogaValue.value);
      break;
    case AUTO:
      setStyleWidthAuto();
      break;
    case PERCENT:
      setStyleWidthPercent(mTempYogaValue.value);
      break;
  }

  width.recycle();
}
 
Example 12
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.MIN_WIDTH)
public void setMinWidth(Dynamic minWidth) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(minWidth);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleMinWidth(mTempYogaValue.value);
      break;
    case PERCENT:
      setStyleMinWidthPercent(mTempYogaValue.value);
      break;
  }

  minWidth.recycle();
}
 
Example 13
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.MAX_WIDTH)
public void setMaxWidth(Dynamic maxWidth) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(maxWidth);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleMaxWidth(mTempYogaValue.value);
      break;
    case PERCENT:
      setStyleMaxWidthPercent(mTempYogaValue.value);
      break;
  }

  maxWidth.recycle();
}
 
Example 14
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.HEIGHT)
public void setHeight(Dynamic height) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(height);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleHeight(mTempYogaValue.value);
      break;
    case AUTO:
      setStyleHeightAuto();
      break;
    case PERCENT:
      setStyleHeightPercent(mTempYogaValue.value);
      break;
  }

  height.recycle();
}
 
Example 15
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.MIN_HEIGHT)
public void setMinHeight(Dynamic minHeight) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(minHeight);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleMinHeight(mTempYogaValue.value);
      break;
    case PERCENT:
      setStyleMinHeightPercent(mTempYogaValue.value);
      break;
  }

  minHeight.recycle();
}
 
Example 16
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.MAX_HEIGHT)
public void setMaxHeight(Dynamic maxHeight) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(maxHeight);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setStyleMaxHeight(mTempYogaValue.value);
      break;
    case PERCENT:
      setStyleMaxHeightPercent(mTempYogaValue.value);
      break;
  }

  maxHeight.recycle();
}
 
Example 17
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactProp(name = ViewProps.FLEX_BASIS)
public void setFlexBasis(Dynamic flexBasis) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(flexBasis);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setFlexBasis(mTempYogaValue.value);
      break;
    case AUTO:
      setFlexBasisAuto();
      break;
    case PERCENT:
      setFlexBasisPercent(mTempYogaValue.value);
      break;
  }

  flexBasis.recycle();
}
 
Example 18
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 6 votes vote down vote up
@ReactPropGroup(names = {
    ViewProps.LEFT,
    ViewProps.RIGHT,
    ViewProps.TOP,
    ViewProps.BOTTOM,
})
public void setPositionValues(int index, Dynamic position) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(position);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setPosition(ViewProps.POSITION_SPACING_TYPES[index], mTempYogaValue.value);
      break;
    case PERCENT:
      setPositionPercent(ViewProps.POSITION_SPACING_TYPES[index], mTempYogaValue.value);
      break;
  }

  position.recycle();
}
 
Example 19
Project: react-native-calendar-events   File: CalendarEvents.java   View source code 6 votes vote down vote up
@ReactMethod
public void findAllEvents(final Dynamic startDate, final Dynamic endDate, final ReadableArray calendars, final Promise promise) {

    if (this.haveCalendarReadWritePermissions()) {
        try {
            Thread thread = new Thread(new Runnable(){
                @Override
                public void run() {
                    WritableNativeArray results = findEvents(startDate, endDate, calendars);
                    promise.resolve(results);
                }
            });
            thread.start();

        } catch (Exception e) {
            promise.reject("find event error", e.getMessage());
        }
    } else {
        promise.reject("find event error", "you don't have permissions to read an event from the users calendar");
    }

}
 
Example 20
Project: RNLearn_Project1   File: FrescoBasedReactTextInlineImageShadowNode.java   View source code 5 votes vote down vote up
/**
 * Besides width/height, all other layout props on inline images are ignored
 */
@Override
public void setWidth(Dynamic width) {
  if (width.getType() == ReadableType.Number) {
    mWidth = (float) width.asDouble();
  } else {
    throw new JSApplicationIllegalArgumentException(
        "Inline images must not have percentage based width");
  }
}
 
Example 21
Project: RNLearn_Project1   File: FrescoBasedReactTextInlineImageShadowNode.java   View source code 5 votes vote down vote up
@Override
public void setHeight(Dynamic height) {
  if (height.getType() == ReadableType.Number) {
    mHeight = (float) height.asDouble();
  } else {
    throw new JSApplicationIllegalArgumentException(
        "Inline images must not have percentage based height");
  }
}
 
Example 22
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 5 votes vote down vote up
@ReactPropGroup(names = {
    ViewProps.MARGIN,
    ViewProps.MARGIN_VERTICAL,
    ViewProps.MARGIN_HORIZONTAL,
    ViewProps.MARGIN_LEFT,
    ViewProps.MARGIN_RIGHT,
    ViewProps.MARGIN_TOP,
    ViewProps.MARGIN_BOTTOM,
})
public void setMargins(int index, Dynamic margin) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(margin);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setMargin(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
      break;
    case AUTO:
      setMarginAuto(ViewProps.PADDING_MARGIN_SPACING_TYPES[index]);
      break;
    case PERCENT:
      setMarginPercent(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
      break;
  }

  margin.recycle();
}
 
Example 23
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 5 votes vote down vote up
@ReactPropGroup(names = {
    ViewProps.PADDING,
    ViewProps.PADDING_VERTICAL,
    ViewProps.PADDING_HORIZONTAL,
    ViewProps.PADDING_LEFT,
    ViewProps.PADDING_RIGHT,
    ViewProps.PADDING_TOP,
    ViewProps.PADDING_BOTTOM,
})
public void setPaddings(int index, Dynamic padding) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(padding);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setPadding(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
      break;
    case PERCENT:
      setPaddingPercent(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
      break;
  }

  padding.recycle();
}
 
Example 24
Project: RNLearn_Project1   File: ViewManagersPropertyCache.java   View source code 5 votes vote down vote up
private static PropSetter createPropSetter(
    ReactProp annotation,
    Method method,
    Class<?> propTypeClass) {
  if (propTypeClass == Dynamic.class) {
    return new DynamicPropSetter(annotation, method);
  } else if (propTypeClass == boolean.class) {
    return new BooleanPropSetter(annotation, method, annotation.defaultBoolean());
  } else if (propTypeClass == int.class) {
    return new IntPropSetter(annotation, method, annotation.defaultInt());
  } else if (propTypeClass == float.class) {
    return new FloatPropSetter(annotation, method, annotation.defaultFloat());
  } else if (propTypeClass == double.class) {
    return new DoublePropSetter(annotation, method, annotation.defaultDouble());
  } else if (propTypeClass == String.class) {
    return new StringPropSetter(annotation, method);
  } else if (propTypeClass == Boolean.class) {
    return new BoxedBooleanPropSetter(annotation, method);
  } else if (propTypeClass == Integer.class) {
    return new BoxedIntPropSetter(annotation, method);
  } else if (propTypeClass == ReadableArray.class) {
    return new ArrayPropSetter(annotation, method);
  } else if (propTypeClass == ReadableMap.class) {
    return new MapPropSetter(annotation, method);
  } else {
    throw new RuntimeException("Unrecognized type: " + propTypeClass + " for method: " +
        method.getDeclaringClass().getName() + "#" + method.getName());
  }
}
 
Example 25
Project: RNLearn_Project1   File: CatalystNativeJSToJavaParametersTestCase.java   View source code 5 votes vote down vote up
public void testDynamicType() {
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnDynamicTypes();
  waitForBridgeAndUIIdle();

  List<Dynamic> dynamicCalls = mRecordingTestModule.getDynamicCalls();
  assertEquals(2, dynamicCalls.size());

  assertEquals("foo", dynamicCalls.get(0).asString());
  assertEquals(3.14, dynamicCalls.get(1).asDouble());
}
 
Example 26
Project: RNLearn_Project1   File: FrescoBasedReactTextInlineImageShadowNode.java   View source code 5 votes vote down vote up
/**
 * Besides width/height, all other layout props on inline images are ignored
 */
@Override
public void setWidth(Dynamic width) {
  if (width.getType() == ReadableType.Number) {
    mWidth = (float) width.asDouble();
  } else {
    throw new JSApplicationIllegalArgumentException(
        "Inline images must not have percentage based width");
  }
}
 
Example 27
Project: RNLearn_Project1   File: FrescoBasedReactTextInlineImageShadowNode.java   View source code 5 votes vote down vote up
@Override
public void setHeight(Dynamic height) {
  if (height.getType() == ReadableType.Number) {
    mHeight = (float) height.asDouble();
  } else {
    throw new JSApplicationIllegalArgumentException(
        "Inline images must not have percentage based height");
  }
}
 
Example 28
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 5 votes vote down vote up
@ReactPropGroup(names = {
    ViewProps.MARGIN,
    ViewProps.MARGIN_VERTICAL,
    ViewProps.MARGIN_HORIZONTAL,
    ViewProps.MARGIN_LEFT,
    ViewProps.MARGIN_RIGHT,
    ViewProps.MARGIN_TOP,
    ViewProps.MARGIN_BOTTOM,
})
public void setMargins(int index, Dynamic margin) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(margin);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setMargin(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
      break;
    case AUTO:
      setMarginAuto(ViewProps.PADDING_MARGIN_SPACING_TYPES[index]);
      break;
    case PERCENT:
      setMarginPercent(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
      break;
  }

  margin.recycle();
}
 
Example 29
Project: RNLearn_Project1   File: LayoutShadowNode.java   View source code 5 votes vote down vote up
@ReactPropGroup(names = {
    ViewProps.PADDING,
    ViewProps.PADDING_VERTICAL,
    ViewProps.PADDING_HORIZONTAL,
    ViewProps.PADDING_LEFT,
    ViewProps.PADDING_RIGHT,
    ViewProps.PADDING_TOP,
    ViewProps.PADDING_BOTTOM,
})
public void setPaddings(int index, Dynamic padding) {
  if (isVirtual()) {
    return;
  }

  mTempYogaValue.setFromDynamic(padding);
  switch (mTempYogaValue.unit) {
    case POINT:
    case UNDEFINED:
      setPadding(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
      break;
    case PERCENT:
      setPaddingPercent(ViewProps.PADDING_MARGIN_SPACING_TYPES[index], mTempYogaValue.value);
      break;
  }

  padding.recycle();
}
 
Example 30
Project: RNLearn_Project1   File: ViewManagersPropertyCache.java   View source code 5 votes vote down vote up
private static PropSetter createPropSetter(
    ReactProp annotation,
    Method method,
    Class<?> propTypeClass) {
  if (propTypeClass == Dynamic.class) {
    return new DynamicPropSetter(annotation, method);
  } else if (propTypeClass == boolean.class) {
    return new BooleanPropSetter(annotation, method, annotation.defaultBoolean());
  } else if (propTypeClass == int.class) {
    return new IntPropSetter(annotation, method, annotation.defaultInt());
  } else if (propTypeClass == float.class) {
    return new FloatPropSetter(annotation, method, annotation.defaultFloat());
  } else if (propTypeClass == double.class) {
    return new DoublePropSetter(annotation, method, annotation.defaultDouble());
  } else if (propTypeClass == String.class) {
    return new StringPropSetter(annotation, method);
  } else if (propTypeClass == Boolean.class) {
    return new BoxedBooleanPropSetter(annotation, method);
  } else if (propTypeClass == Integer.class) {
    return new BoxedIntPropSetter(annotation, method);
  } else if (propTypeClass == ReadableArray.class) {
    return new ArrayPropSetter(annotation, method);
  } else if (propTypeClass == ReadableMap.class) {
    return new MapPropSetter(annotation, method);
  } else {
    throw new RuntimeException("Unrecognized type: " + propTypeClass + " for method: " +
        method.getDeclaringClass().getName() + "#" + method.getName());
  }
}
 
Example 31
Project: RNLearn_Project1   File: CatalystNativeJSToJavaParametersTestCase.java   View source code 5 votes vote down vote up
public void testDynamicType() {
  mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnDynamicTypes();
  waitForBridgeAndUIIdle();

  List<Dynamic> dynamicCalls = mRecordingTestModule.getDynamicCalls();
  assertEquals(2, dynamicCalls.size());

  assertEquals("foo", dynamicCalls.get(0).asString());
  assertEquals(3.14, dynamicCalls.get(1).asDouble());
}
 
Example 32
Project: RNLearn_Project1   File: ReactStylesDiffMap.java   View source code 4 votes vote down vote up
@Nullable
public Dynamic getDynamic(String key) {
  return mBackingMap.getDynamic(key);
}
 
Example 33
Project: RNLearn_Project1   File: ViewManagersPropertyCache.java   View source code 4 votes vote down vote up
private static void createPropSetters(
    ReactPropGroup annotation,
    Method method,
    Class<?> propTypeClass,
    Map<String, PropSetter> props) {
  String[] names = annotation.names();
  if (propTypeClass == Dynamic.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new DynamicPropSetter(annotation, method, i));
    }
  } else if (propTypeClass == int.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new IntPropSetter(annotation, method, i, annotation.defaultInt()));
    }
  } else if (propTypeClass == float.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new FloatPropSetter(annotation, method, i, annotation.defaultFloat()));
    }
  } else if (propTypeClass == double.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new DoublePropSetter(annotation, method, i, annotation.defaultDouble()));
    }
  } else if (propTypeClass == Integer.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new BoxedIntPropSetter(annotation, method, i));
    }
  } else {
    throw new RuntimeException("Unrecognized type: " + propTypeClass + " for method: " +
        method.getDeclaringClass().getName() + "#" + method.getName());
  }
}
 
Example 34
Project: RNLearn_Project1   File: CatalystNativeJSToJavaParametersTestCase.java   View source code 4 votes vote down vote up
@ReactMethod
public void receiveDynamic(Dynamic dynamic) {
  mDynamicCalls.add(dynamic);
}
 
Example 35
Project: RNLearn_Project1   File: CatalystNativeJSToJavaParametersTestCase.java   View source code 4 votes vote down vote up
public List<Dynamic> getDynamicCalls() {
  return mDynamicCalls;
}
 
Example 36
Project: RNLearn_Project1   File: ReactStylesDiffMap.java   View source code 4 votes vote down vote up
@Nullable
public Dynamic getDynamic(String key) {
  return mBackingMap.getDynamic(key);
}
 
Example 37
Project: RNLearn_Project1   File: ViewManagersPropertyCache.java   View source code 4 votes vote down vote up
private static void createPropSetters(
    ReactPropGroup annotation,
    Method method,
    Class<?> propTypeClass,
    Map<String, PropSetter> props) {
  String[] names = annotation.names();
  if (propTypeClass == Dynamic.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new DynamicPropSetter(annotation, method, i));
    }
  } else if (propTypeClass == int.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new IntPropSetter(annotation, method, i, annotation.defaultInt()));
    }
  } else if (propTypeClass == float.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new FloatPropSetter(annotation, method, i, annotation.defaultFloat()));
    }
  } else if (propTypeClass == double.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new DoublePropSetter(annotation, method, i, annotation.defaultDouble()));
    }
  } else if (propTypeClass == Integer.class) {
    for (int i = 0; i < names.length; i++) {
      props.put(
          names[i],
          new BoxedIntPropSetter(annotation, method, i));
    }
  } else {
    throw new RuntimeException("Unrecognized type: " + propTypeClass + " for method: " +
        method.getDeclaringClass().getName() + "#" + method.getName());
  }
}
 
Example 38
Project: RNLearn_Project1   File: CatalystNativeJSToJavaParametersTestCase.java   View source code 4 votes vote down vote up
@ReactMethod
public void receiveDynamic(Dynamic dynamic) {
  mDynamicCalls.add(dynamic);
}
 
Example 39
Project: RNLearn_Project1   File: CatalystNativeJSToJavaParametersTestCase.java   View source code 4 votes vote down vote up
public List<Dynamic> getDynamicCalls() {
  return mDynamicCalls;
}
 
Example 40
Project: rn-notification   File: WritableNativeMap.java   View source code 4 votes vote down vote up
@Override
public Dynamic getDynamic(String name) {
    return (Dynamic) this.get(name);
}