com.facebook.react.bridge.Dynamic Java Examples
The following examples show how to use
com.facebook.react.bridge.Dynamic.
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 |
@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 #2
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 6 votes |
@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 #3
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 6 votes |
@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 #4
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 6 votes |
@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
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 6 votes |
@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 #6
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 6 votes |
@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 #7
Source File: ReactDrawerLayoutManager_1d0b39_t.java From coming with MIT License | 6 votes |
@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 #8
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 6 votes |
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 #9
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 6 votes |
@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 #10
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 5 votes |
@ReactPropGroup( names = { ViewProps.START, ViewProps.END, ViewProps.LEFT, ViewProps.RIGHT, ViewProps.TOP, ViewProps.BOTTOM, } ) public void setPositionValues(int index, Dynamic position) { if (isVirtual()) { return; } final int[] POSITION_SPACING_TYPES = { Spacing.START, Spacing.END, Spacing.LEFT, Spacing.RIGHT, Spacing.TOP, Spacing.BOTTOM }; int spacingType = maybeTransformLeftRightToStartEnd(POSITION_SPACING_TYPES[index]); mTempYogaValue.setFromDynamic(position); switch (mTempYogaValue.unit) { case POINT: case UNDEFINED: setPosition(spacingType, mTempYogaValue.value); break; case PERCENT: setPositionPercent(spacingType, mTempYogaValue.value); break; } position.recycle(); }
Example #11
Source File: FrescoBasedReactTextInlineImageShadowNode.java From react-native-GPay with MIT License | 5 votes |
@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 #12
Source File: FrescoBasedReactTextInlineImageShadowNode.java From react-native-GPay with MIT License | 5 votes |
/** * 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 #13
Source File: RNKakaoLinkModule.java From react-native-kakao-links with MIT License | 5 votes |
@Override public Dynamic getDynamic(String name) { if (map.hasKey(name)) { return map.getDynamic(name); } else { return null; } }
Example #14
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 5 votes |
@ReactPropGroup( names = { ViewProps.MARGIN, ViewProps.MARGIN_VERTICAL, ViewProps.MARGIN_HORIZONTAL, ViewProps.MARGIN_START, ViewProps.MARGIN_END, ViewProps.MARGIN_TOP, ViewProps.MARGIN_BOTTOM, ViewProps.MARGIN_LEFT, ViewProps.MARGIN_RIGHT, } ) public void setMargins(int index, Dynamic margin) { if (isVirtual()) { return; } int spacingType = maybeTransformLeftRightToStartEnd(ViewProps.PADDING_MARGIN_SPACING_TYPES[index]); mTempYogaValue.setFromDynamic(margin); switch (mTempYogaValue.unit) { case POINT: case UNDEFINED: setMargin(spacingType, mTempYogaValue.value); break; case AUTO: setMarginAuto(spacingType); break; case PERCENT: setMarginPercent(spacingType, mTempYogaValue.value); break; } margin.recycle(); }
Example #15
Source File: LayoutShadowNode.java From react-native-GPay with MIT License | 5 votes |
@ReactPropGroup( names = { ViewProps.PADDING, ViewProps.PADDING_VERTICAL, ViewProps.PADDING_HORIZONTAL, ViewProps.PADDING_START, ViewProps.PADDING_END, ViewProps.PADDING_TOP, ViewProps.PADDING_BOTTOM, ViewProps.PADDING_LEFT, ViewProps.PADDING_RIGHT, } ) public void setPaddings(int index, Dynamic padding) { if (isVirtual()) { return; } int spacingType = maybeTransformLeftRightToStartEnd(ViewProps.PADDING_MARGIN_SPACING_TYPES[index]); mTempYogaValue.setFromDynamic(padding); switch (mTempYogaValue.unit) { case POINT: case UNDEFINED: setPadding(spacingType, mTempYogaValue.value); break; case PERCENT: setPaddingPercent(spacingType, mTempYogaValue.value); break; } padding.recycle(); }
Example #16
Source File: ViewManagersPropertyCache.java From react-native-GPay with MIT License | 5 votes |
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 #17
Source File: CatalystNativeJSToJavaParametersTestCase.java From react-native-GPay with MIT License | 5 votes |
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 #18
Source File: ReactExoplayerViewManager.java From react-native-video with MIT License | 5 votes |
@ReactProp(name = PROP_SELECTED_VIDEO_TRACK) public void setSelectedVideoTrack(final ReactExoplayerView videoView, @Nullable ReadableMap selectedVideoTrack) { String typeString = null; Dynamic value = null; if (selectedVideoTrack != null) { typeString = selectedVideoTrack.hasKey(PROP_SELECTED_VIDEO_TRACK_TYPE) ? selectedVideoTrack.getString(PROP_SELECTED_VIDEO_TRACK_TYPE) : null; value = selectedVideoTrack.hasKey(PROP_SELECTED_VIDEO_TRACK_VALUE) ? selectedVideoTrack.getDynamic(PROP_SELECTED_VIDEO_TRACK_VALUE) : null; } videoView.setSelectedVideoTrack(typeString, value); }
Example #19
Source File: ReactExoplayerViewManager.java From react-native-video with MIT License | 5 votes |
@ReactProp(name = PROP_SELECTED_AUDIO_TRACK) public void setSelectedAudioTrack(final ReactExoplayerView videoView, @Nullable ReadableMap selectedAudioTrack) { String typeString = null; Dynamic value = null; if (selectedAudioTrack != null) { typeString = selectedAudioTrack.hasKey(PROP_SELECTED_AUDIO_TRACK_TYPE) ? selectedAudioTrack.getString(PROP_SELECTED_AUDIO_TRACK_TYPE) : null; value = selectedAudioTrack.hasKey(PROP_SELECTED_AUDIO_TRACK_VALUE) ? selectedAudioTrack.getDynamic(PROP_SELECTED_AUDIO_TRACK_VALUE) : null; } videoView.setSelectedAudioTrack(typeString, value); }
Example #20
Source File: ReactExoplayerViewManager.java From react-native-video with MIT License | 5 votes |
@ReactProp(name = PROP_SELECTED_TEXT_TRACK) public void setSelectedTextTrack(final ReactExoplayerView videoView, @Nullable ReadableMap selectedTextTrack) { String typeString = null; Dynamic value = null; if (selectedTextTrack != null) { typeString = selectedTextTrack.hasKey(PROP_SELECTED_TEXT_TRACK_TYPE) ? selectedTextTrack.getString(PROP_SELECTED_TEXT_TRACK_TYPE) : null; value = selectedTextTrack.hasKey(PROP_SELECTED_TEXT_TRACK_VALUE) ? selectedTextTrack.getDynamic(PROP_SELECTED_TEXT_TRACK_VALUE) : null; } videoView.setSelectedTextTrack(typeString, value); }
Example #21
Source File: ReactExoplayerView.java From react-native-video with MIT License | 4 votes |
public void setSelectedTextTrack(String type, Dynamic value) { textTrackType = type; textTrackValue = value; setSelectedTrack(C.TRACK_TYPE_TEXT, textTrackType, textTrackValue); }
Example #22
Source File: ViewManagersPropertyCache.java From react-native-GPay with MIT License | 4 votes |
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 #23
Source File: CatalystNativeJSToJavaParametersTestCase.java From react-native-GPay with MIT License | 4 votes |
@ReactMethod public void receiveDynamic(Dynamic dynamic) { mDynamicCalls.add(dynamic); }
Example #24
Source File: CatalystNativeJSToJavaParametersTestCase.java From react-native-GPay with MIT License | 4 votes |
public List<Dynamic> getDynamicCalls() { return mDynamicCalls; }
Example #25
Source File: EmptyReadableArray.java From react-native-paged-contacts with MIT License | 4 votes |
@NonNull @Override public Dynamic getDynamic(int index) { return null; }
Example #26
Source File: ReactExoplayerView.java From react-native-video with MIT License | 4 votes |
public void setSelectedVideoTrack(String type, Dynamic value) { videoTrackType = type; videoTrackValue = value; setSelectedTrack(C.TRACK_TYPE_VIDEO, videoTrackType, videoTrackValue); }
Example #27
Source File: ReactExoplayerView.java From react-native-video with MIT License | 4 votes |
public void setSelectedAudioTrack(String type, Dynamic value) { audioTrackType = type; audioTrackValue = value; setSelectedTrack(C.TRACK_TYPE_AUDIO, audioTrackType, audioTrackValue); }
Example #28
Source File: PickerView.java From react-native-date-picker with MIT License | 4 votes |
public void updateProp(String propName, Dynamic value) { state.setProp(propName, value); updatedProps.add(propName); }
Example #29
Source File: MaximumDateProp.java From react-native-date-picker with MIT License | 4 votes |
@Override public String toValue(Dynamic value){ return value.asString(); }
Example #30
Source File: LocaleProp.java From react-native-date-picker with MIT License | 4 votes |
@Override public Locale toValue(Dynamic value){ this.languageTag = value.asString().replace('-','_'); return LocaleUtils.getLocale(languageTag); }