Java Code Examples for com.facebook.react.uimanager.PixelUtil#toPixelFromDIP()
The following examples show how to use
com.facebook.react.uimanager.PixelUtil#toPixelFromDIP() .
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: ReactTextInputManager.java From react-native-GPay with MIT License | 6 votes |
@ReactPropGroup(names = { ViewProps.BORDER_RADIUS, ViewProps.BORDER_TOP_LEFT_RADIUS, ViewProps.BORDER_TOP_RIGHT_RADIUS, ViewProps.BORDER_BOTTOM_RIGHT_RADIUS, ViewProps.BORDER_BOTTOM_LEFT_RADIUS }, defaultFloat = YogaConstants.UNDEFINED) public void setBorderRadius(ReactEditText view, int index, float borderRadius) { if (!YogaConstants.isUndefined(borderRadius)) { borderRadius = PixelUtil.toPixelFromDIP(borderRadius); } if (index == 0) { view.setBorderRadius(borderRadius); } else { view.setBorderRadius(borderRadius, index - 1); } }
Example 2
Source File: ViewRenderingTestCase.java From react-native-GPay with MIT License | 6 votes |
public void testTransformations() { mCatalystInstance.getJSModule(ViewRenderingTestModule.class) .renderTransformApplication(mRootTag); waitForBridgeAndUIIdle(); View view = getViewAtPath(mRootView); float expectedTranslateX = PixelUtil.toPixelFromDIP(20); float expectedTranslateY = PixelUtil.toPixelFromDIP(25); assertEquals(5f, view.getScaleX()); assertEquals(10f, view.getScaleY()); assertEquals(15f, view.getRotation()); assertEquals(expectedTranslateX, view.getTranslationX()); assertEquals(expectedTranslateY, view.getTranslationY()); }
Example 3
Source File: ReactScrollViewManager.java From react-native-GPay with MIT License | 6 votes |
@ReactPropGroup(names = { ViewProps.BORDER_RADIUS, ViewProps.BORDER_TOP_LEFT_RADIUS, ViewProps.BORDER_TOP_RIGHT_RADIUS, ViewProps.BORDER_BOTTOM_RIGHT_RADIUS, ViewProps.BORDER_BOTTOM_LEFT_RADIUS }, defaultFloat = YogaConstants.UNDEFINED) public void setBorderRadius(ReactScrollView view, int index, float borderRadius) { if (!YogaConstants.isUndefined(borderRadius)) { borderRadius = PixelUtil.toPixelFromDIP(borderRadius); } if (index == 0) { view.setBorderRadius(borderRadius); } else { view.setBorderRadius(borderRadius, index - 1); } }
Example 4
Source File: ReactViewManager.java From react-native-GPay with MIT License | 6 votes |
@ReactPropGroup( names = { ViewProps.BORDER_WIDTH, ViewProps.BORDER_LEFT_WIDTH, ViewProps.BORDER_RIGHT_WIDTH, ViewProps.BORDER_TOP_WIDTH, ViewProps.BORDER_BOTTOM_WIDTH, ViewProps.BORDER_START_WIDTH, ViewProps.BORDER_END_WIDTH, }, defaultFloat = YogaConstants.UNDEFINED ) public void setBorderWidth(ReactViewGroup view, int index, float width) { if (!YogaConstants.isUndefined(width) && width < 0) { width = YogaConstants.UNDEFINED; } if (!YogaConstants.isUndefined(width)) { width = PixelUtil.toPixelFromDIP(width); } view.setBorderWidth(SPACING_TYPES[index], width); }
Example 5
Source File: ReactViewManager.java From react-native-GPay with MIT License | 6 votes |
@Override public void receiveCommand(ReactViewGroup root, int commandId, @Nullable ReadableArray args) { switch (commandId) { case CMD_HOTSPOT_UPDATE: { if (args == null || args.size() != 2) { throw new JSApplicationIllegalArgumentException( "Illegal number of arguments for 'updateHotspot' command"); } if (Build.VERSION.SDK_INT >= 21) { float x = PixelUtil.toPixelFromDIP(args.getDouble(0)); float y = PixelUtil.toPixelFromDIP(args.getDouble(1)); root.drawableHotspotChanged(x, y); } break; } case CMD_SET_PRESSED: { if (args == null || args.size() != 1) { throw new JSApplicationIllegalArgumentException( "Illegal number of arguments for 'setPressed' command"); } root.setPressed(args.getBoolean(0)); break; } } }
Example 6
Source File: FrescoBasedReactTextInlineImageSpan.java From react-native-GPay with MIT License | 6 votes |
public FrescoBasedReactTextInlineImageSpan( Resources resources, int height, int width, int tintColor, @Nullable Uri uri, ReadableMap headers, AbstractDraweeControllerBuilder draweeControllerBuilder, @Nullable Object callerContext) { mDraweeHolder = new DraweeHolder( GenericDraweeHierarchyBuilder.newInstance(resources) .build() ); mDraweeControllerBuilder = draweeControllerBuilder; mCallerContext = callerContext; mTintColor = tintColor; mUri = (uri != null) ? uri : Uri.EMPTY; mHeaders = headers; mWidth = (int)(PixelUtil.toPixelFromDIP(width)); mHeight = (int)(PixelUtil.toPixelFromDIP(height)); }
Example 7
Source File: ReactTextAnchorViewManager.java From react-native-GPay with MIT License | 6 votes |
@ReactPropGroup( names = { ViewProps.BORDER_WIDTH, ViewProps.BORDER_LEFT_WIDTH, ViewProps.BORDER_RIGHT_WIDTH, ViewProps.BORDER_TOP_WIDTH, ViewProps.BORDER_BOTTOM_WIDTH, }, defaultFloat = YogaConstants.UNDEFINED ) public void setBorderWidth(ReactTextView view, int index, float width) { if (!YogaConstants.isUndefined(width)) { width = PixelUtil.toPixelFromDIP(width); } view.setBorderWidth(SPACING_TYPES[index], width); }
Example 8
Source File: ReactBaseTextShadowNode.java From react-native-GPay with MIT License | 6 votes |
@ReactProp(name = PROP_SHADOW_OFFSET) public void setTextShadowOffset(ReadableMap offsetMap) { mTextShadowOffsetDx = 0; mTextShadowOffsetDy = 0; if (offsetMap != null) { if (offsetMap.hasKey(PROP_SHADOW_OFFSET_WIDTH) && !offsetMap.isNull(PROP_SHADOW_OFFSET_WIDTH)) { mTextShadowOffsetDx = PixelUtil.toPixelFromDIP(offsetMap.getDouble(PROP_SHADOW_OFFSET_WIDTH)); } if (offsetMap.hasKey(PROP_SHADOW_OFFSET_HEIGHT) && !offsetMap.isNull(PROP_SHADOW_OFFSET_HEIGHT)) { mTextShadowOffsetDy = PixelUtil.toPixelFromDIP(offsetMap.getDouble(PROP_SHADOW_OFFSET_HEIGHT)); } } markUpdated(); }
Example 9
Source File: JSResponderTestCase.java From react-native-GPay with MIT License | 5 votes |
public void testResponderLocksScrollView() { ScrollView scrollView = getViewByTestId("scroll_view"); assertNotNull(scrollView); assertEquals(0, scrollView.getScrollY()); float inpx40dp = PixelUtil.toPixelFromDIP(40f); float inpx100dp = PixelUtil.toPixelFromDIP(100f); SingleTouchGestureGenerator gestureGenerator = createGestureGenerator(); gestureGenerator .startGesture(30, 30 + inpx100dp) .dragTo(30 + inpx40dp, 30, 10, 1200) .endGesture(180, 100); waitForBridgeAndUIIdle(); assertTrue("Expected to scroll by at least 80 dp", scrollView.getScrollY() >= inpx100dp * .8f); int previousScroll = scrollView.getScrollY(); gestureGenerator .startGesture(30, 30 + inpx100dp) .dragTo(30 + inpx40dp, 30 + inpx100dp, 10, 1200); waitForBridgeAndUIIdle(); gestureGenerator .dragTo(30 + inpx40dp, 30, 10, 1200) .endGesture(); waitForBridgeAndUIIdle(); assertEquals("Expected not to scroll", scrollView.getScrollY(), previousScroll); }
Example 10
Source File: ReactHorizontalScrollViewManager.java From react-native-GPay with MIT License | 5 votes |
@ReactPropGroup(names = { ViewProps.BORDER_WIDTH, ViewProps.BORDER_LEFT_WIDTH, ViewProps.BORDER_RIGHT_WIDTH, ViewProps.BORDER_TOP_WIDTH, ViewProps.BORDER_BOTTOM_WIDTH, }, defaultFloat = YogaConstants.UNDEFINED) public void setBorderWidth(ReactHorizontalScrollView view, int index, float width) { if (!YogaConstants.isUndefined(width)) { width = PixelUtil.toPixelFromDIP(width); } view.setBorderWidth(SPACING_TYPES[index], width); }
Example 11
Source File: FloatingActionButtonView.java From react-native-bottom-sheet-behavior with MIT License | 5 votes |
public FloatingActionButtonView(Context context) { super(context); int width = CoordinatorLayout.LayoutParams.WRAP_CONTENT; int height = CoordinatorLayout.LayoutParams.WRAP_CONTENT; CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(width, height); int margin = (int) PixelUtil.toPixelFromDIP(16); params.setMargins(margin, margin, margin, margin); params.anchorGravity = Gravity.TOP | Gravity.RIGHT | Gravity.END; this.setLayoutParams(params); }
Example 12
Source File: ReactBaseTextShadowNode.java From react-native-GPay with MIT License | 5 votes |
@ReactProp(name = ViewProps.LETTER_SPACING, defaultFloat = Float.NaN) public void setLetterSpacing(float letterSpacing) { mLetterSpacingInput = letterSpacing; mLetterSpacing = mAllowFontScaling ? PixelUtil.toPixelFromSP(mLetterSpacingInput) : PixelUtil.toPixelFromDIP(mLetterSpacingInput); markUpdated(); }
Example 13
Source File: ReactBaseTextShadowNode.java From react-native-GPay with MIT License | 5 votes |
@ReactProp(name = ViewProps.LINE_HEIGHT, defaultFloat = UNSET) public void setLineHeight(float lineHeight) { mLineHeightInput = lineHeight; if (lineHeight == UNSET) { mLineHeight = Float.NaN; } else { mLineHeight = mAllowFontScaling ? PixelUtil.toPixelFromSP(lineHeight) : PixelUtil.toPixelFromDIP(lineHeight); } markUpdated(); }
Example 14
Source File: ReactTextInputManager.java From react-native-GPay with MIT License | 5 votes |
@ReactPropGroup(names = { ViewProps.BORDER_WIDTH, ViewProps.BORDER_LEFT_WIDTH, ViewProps.BORDER_RIGHT_WIDTH, ViewProps.BORDER_TOP_WIDTH, ViewProps.BORDER_BOTTOM_WIDTH, }, defaultFloat = YogaConstants.UNDEFINED) public void setBorderWidth(ReactEditText view, int index, float width) { if (!YogaConstants.isUndefined(width)) { width = PixelUtil.toPixelFromDIP(width); } view.setBorderWidth(SPACING_TYPES[index], width); }
Example 15
Source File: ScrollingAppBarLayoutManager.java From react-native-bottom-sheet-behavior with MIT License | 4 votes |
@ReactProp(name = "height") public void setHeight(AppBarLayout view, int height) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams(); params.height = (int) PixelUtil.toPixelFromDIP(height); view.setLayoutParams(params); }
Example 16
Source File: MergedAppBarLayoutManager.java From react-native-bottom-sheet-behavior with MIT License | 4 votes |
@ReactProp(name = "height") public void setHeight(AppBarLayout view, int height) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams(); params.height = (int) PixelUtil.toPixelFromDIP(height); view.setLayoutParams(params); }
Example 17
Source File: BottomSheetBehaviorView.java From react-native-bottom-sheet-behavior with MIT License | 4 votes |
public void setAnchorPoint(int anchorPoint) { int anchorPointPixel = (int) PixelUtil.toPixelFromDIP(anchorPoint); behavior.setAnchorPoint(anchorPointPixel); }
Example 18
Source File: ReactImageView.java From react-native-GPay with MIT License | 4 votes |
public void setBorderWidth(float borderWidth) { mBorderWidth = PixelUtil.toPixelFromDIP(borderWidth); mIsDirty = true; }
Example 19
Source File: ReactRootView.java From react-native-GPay with MIT License | 4 votes |
CustomGlobalLayoutListener() { DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(getContext().getApplicationContext()); mVisibleViewArea = new Rect(); mMinKeyboardHeightDetected = (int) PixelUtil.toPixelFromDIP(60); }
Example 20
Source File: RNTextSizeConf.java From react-native-text-size with BSD 2-Clause "Simplified" License | 4 votes |
float scale(final float measure) { return allowFontScaling ? PixelUtil.toPixelFromSP(measure) : PixelUtil.toPixelFromDIP(measure); }