|
7 | 7 |
|
8 | 8 | package com.facebook.react.views.view; |
9 | 9 |
|
| 10 | +import android.util.Log; |
10 | 11 | import android.content.Context; |
11 | 12 | import android.graphics.Canvas; |
12 | 13 | import android.graphics.Color; |
|
31 | 32 | import com.facebook.yoga.YogaConstants; |
32 | 33 | import java.util.Arrays; |
33 | 34 | import java.util.Locale; |
| 35 | +import java.lang.reflect.Method; |
34 | 36 |
|
35 | 37 | /** |
36 | 38 | * A subclass of {@link Drawable} used for background of {@link ReactViewGroup}. It supports drawing |
@@ -1110,41 +1112,29 @@ private void drawRectangularBackgroundWithBorders(Canvas canvas) { |
1110 | 1112 |
|
1111 | 1113 | mPaint.setColor(fastBorderColor); |
1112 | 1114 | mPaint.setStyle(Paint.Style.STROKE); |
1113 | | - if (borderLeft > 0) { |
1114 | | - mPathForSingleBorder.reset(); |
| 1115 | + if (borderWidth.left > 0) { |
1115 | 1116 | int width = Math.round(borderWidth.left); |
1116 | | - updatePathEffect(width); |
1117 | | - mPaint.setStrokeWidth(width); |
1118 | | - mPathForSingleBorder.moveTo(left, top - borderWidth.top/2); |
1119 | | - mPathForSingleBorder.lineTo(left, bottom + borderWidth.bottom/2); |
1120 | | - canvas.drawPath(mPathForSingleBorder, mPaint); |
| 1117 | + PointF start = new PointF(left, top - borderWidth.top/2); |
| 1118 | + PointF end = new PointF(left, bottom + borderWidth.bottom/2); |
| 1119 | + drawSide(width, start, end, canvas); |
1121 | 1120 | } |
1122 | 1121 | if (borderTop > 0) { |
1123 | | - mPathForSingleBorder.reset(); |
1124 | 1122 | int width = Math.round(borderWidth.top); |
1125 | | - updatePathEffect(width); |
1126 | | - mPaint.setStrokeWidth(width); |
1127 | | - mPathForSingleBorder.moveTo(left, top); |
1128 | | - mPathForSingleBorder.lineTo(right, top); |
1129 | | - canvas.drawPath(mPathForSingleBorder, mPaint); |
| 1123 | + PointF start = new PointF(left, top); |
| 1124 | + PointF end = new PointF(right, top); |
| 1125 | + drawSide(width, start, end, canvas); |
1130 | 1126 | } |
1131 | 1127 | if (borderRight > 0) { |
1132 | | - mPathForSingleBorder.reset(); |
1133 | 1128 | int width = Math.round(borderWidth.right); |
1134 | | - updatePathEffect(width); |
1135 | | - mPaint.setStrokeWidth(width); |
1136 | | - mPathForSingleBorder.moveTo(right, top - borderWidth.top/2); |
1137 | | - mPathForSingleBorder.lineTo(right, bottom + borderWidth.bottom/2); |
1138 | | - canvas.drawPath(mPathForSingleBorder, mPaint); |
| 1129 | + PointF start = new PointF(right, top - borderWidth.top/2); |
| 1130 | + PointF end = new PointF(right, bottom + borderWidth.bottom/2); |
| 1131 | + drawSide(width, start, end, canvas); |
1139 | 1132 | } |
1140 | 1133 | if (borderBottom > 0) { |
1141 | | - mPathForSingleBorder.reset(); |
1142 | 1134 | int width = Math.round(borderWidth.bottom); |
1143 | | - updatePathEffect(width); |
1144 | | - mPaint.setStrokeWidth(width); |
1145 | | - mPathForSingleBorder.moveTo(left, bottom); |
1146 | | - mPathForSingleBorder.lineTo(right, bottom); |
1147 | | - canvas.drawPath(mPathForSingleBorder, mPaint); |
| 1135 | + PointF start = new PointF(left, bottom); |
| 1136 | + PointF end = new PointF(right, bottom); |
| 1137 | + drawSide(width, start, end, canvas); |
1148 | 1138 | } |
1149 | 1139 | } |
1150 | 1140 | } else { |
@@ -1217,6 +1207,15 @@ private void drawRectangularBackgroundWithBorders(Canvas canvas) { |
1217 | 1207 | } |
1218 | 1208 | } |
1219 | 1209 |
|
| 1210 | + private void drawSide(int width, PointF start, PointF end, Canvas canvas) { |
| 1211 | + mPathForSingleBorder.reset(); |
| 1212 | + updatePathEffect(width); |
| 1213 | + mPaint.setStrokeWidth(width); |
| 1214 | + mPathForSingleBorder.moveTo(start.x, start.y); |
| 1215 | + mPathForSingleBorder.lineTo(end.x, end.y); |
| 1216 | + canvas.drawPath(mPathForSingleBorder, mPaint); |
| 1217 | + } |
| 1218 | + |
1220 | 1219 | private void drawQuadrilateral( |
1221 | 1220 | Canvas canvas, |
1222 | 1221 | int fillColor, |
|
0 commit comments