From 491cb4488d1d2fe803f8f6bd74e9652815e6eab5 Mon Sep 17 00:00:00 2001 From: Sokovikov Date: Fri, 29 Apr 2016 04:52:43 -0700 Subject: [PATCH] fix border style without borderRadius Summary: closes #6721 closes #3159 before(without borderRadius) ![bug](https://cloud.githubusercontent.com/assets/1488195/14235087/fcf79f8a-f9eb-11e5-9d44-7ab1d131be24.jpg) after ![fix](https://cloud.githubusercontent.com/assets/1488195/14235067/8cf128b4-f9eb-11e5-8170-ad3a146d6104.jpg) Closes https://github.com/facebook/react-native/pull/6789 Differential Revision: D3240657 Pulled By: mkonicek fb-gh-sync-id: 4eb8f72d7278d880297fb73653ef530719af3d5b fbshipit-source-id: 4eb8f72d7278d880297fb73653ef530719af3d5b --- Examples/UIExplorer/ViewExample.js | 1 - .../view/ReactViewBackgroundDrawable.java | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Examples/UIExplorer/ViewExample.js b/Examples/UIExplorer/ViewExample.js index 4be867b27bc5ce..c5cb7cae73b7d3 100644 --- a/Examples/UIExplorer/ViewExample.js +++ b/Examples/UIExplorer/ViewExample.js @@ -46,7 +46,6 @@ var ViewBorderStyleExample = React.createClass({ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java index fd8961cb8628b6..7aef44b1b4096b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java @@ -95,10 +95,14 @@ private static enum BorderStyle { @Override public void draw(Canvas canvas) { - if ((!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) { - drawRoundedBackgroundWithBorders(canvas); - } else { + updatePathEffect(); + boolean roundedBorders = mBorderCornerRadii != null || + (!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0); + + if ((mBorderStyle == null || mBorderStyle == BorderStyle.SOLID) && !roundedBorders) { drawRectangularBackgroundWithBorders(canvas); + } else { + drawRoundedBackgroundWithBorders(canvas); } } @@ -231,7 +235,6 @@ private void drawRoundedBackgroundWithBorders(Canvas canvas) { mPaint.setColor(ColorUtil.multiplyColorAlpha(borderColor, mAlpha)); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(fullBorderWidth); - mPaint.setPathEffect(mPathEffectForBorderStyle); canvas.drawPath(mPathForBorderRadius, mPaint); } } @@ -298,10 +301,17 @@ private void updatePath() { bottomLeftRadius + extraRadiusForOutline }, Path.Direction.CW); + } + /** + * Set type of border + */ + private void updatePathEffect() { mPathEffectForBorderStyle = mBorderStyle != null ? mBorderStyle.getPathEffect(getFullBorderWidth()) : null; + + mPaint.setPathEffect(mPathEffectForBorderStyle); } /**