Java Code Examples for com.facebook.react.bridge.Dynamic#asString()

The following examples show how to use com.facebook.react.bridge.Dynamic#asString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayoutShadowNode.java    From react-native-GPay with MIT License 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
Source File: ReactDrawerLayoutManager_1d0b39_t.java    From coming with MIT License 6 votes vote down vote up
@ReactProp(name = "drawerPosition")
public void setDrawerPosition(ReactDrawerLayout view, Dynamic drawerPosition) {
  if (drawerPosition.isNull()) {
    view.setDrawerPosition(Gravity.START);
  } else if (drawerPosition.getType() == ReadableType.Number) {
    final int drawerPositionNum = drawerPosition.asInt();

    if (Gravity.START == drawerPositionNum || Gravity.END == drawerPositionNum) {
      view.setDrawerPosition(drawerPositionNum);
    } else {
      throw new JSApplicationIllegalArgumentException("Unknown drawerPosition " + drawerPositionNum);
    }
  } else if (drawerPosition.getType() == ReadableType.String) {
    final String drawerPositionStr = drawerPosition.asString();

    if (drawerPositionStr.equals("left")) {
      view.setDrawerPosition(Gravity.START);
    } else if (drawerPositionStr.equals("right")) {
      view.setDrawerPosition(Gravity.END);
    } else {
      throw new JSApplicationIllegalArgumentException("drawerPosition must be 'left' or 'right', received" + drawerPositionStr);
    }
  } else {
    throw new JSApplicationIllegalArgumentException("drawerPosition must be a string or int");
  }
}
 
Example 3
Source File: FadeToColorProp.java    From react-native-date-picker with MIT License 4 votes vote down vote up
@Override
public String toValue(Dynamic value){
    return value.asString();
}
 
Example 4
Source File: DateProp.java    From react-native-date-picker with MIT License 4 votes vote down vote up
@Override
public String toValue(Dynamic value){
    return value.asString();
}
 
Example 5
Source File: MinimumDateProp.java    From react-native-date-picker with MIT License 4 votes vote down vote up
@Override
public String toValue(Dynamic value){
    return value.asString();
}
 
Example 6
Source File: MaximumDateProp.java    From react-native-date-picker with MIT License 4 votes vote down vote up
@Override
public String toValue(Dynamic value){
    return value.asString();
}
 
Example 7
Source File: TextColorProp.java    From react-native-date-picker with MIT License 4 votes vote down vote up
@Override
public String toValue(Dynamic value){
    return value.asString();
}