Skip to content

Commit 25a40cb

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Clean old code on ReactViewBackgroundDrawable
Summary: This diff removes unnecessary API checks in ReactViewBackgroundDrawable changelog: [Android][Deprecated] Remove JellyBeans Android API checks in ReactViewBackgroundDrawable classes Reviewed By: JoshuaGross Differential Revision: D22771911 fbshipit-source-id: bbbf3dd3fd1c3cf3f5ce294fc32bd0a31ca0f67c
1 parent 799654b commit 25a40cb

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java

+30-32
Original file line numberDiff line numberDiff line change
@@ -378,43 +378,41 @@ private void drawRoundedBackgroundWithBorders(Canvas canvas) {
378378
canvas.clipPath(mOuterClipPathForBorderRadius, Region.Op.INTERSECT);
379379
canvas.clipPath(mInnerClipPathForBorderRadius, Region.Op.DIFFERENCE);
380380

381-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
382-
final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
383-
int colorStart = getBorderColor(Spacing.START);
384-
int colorEnd = getBorderColor(Spacing.END);
381+
final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
382+
int colorStart = getBorderColor(Spacing.START);
383+
int colorEnd = getBorderColor(Spacing.END);
385384

386-
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
387-
if (!isBorderColorDefined(Spacing.START)) {
388-
colorStart = colorLeft;
389-
}
385+
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
386+
if (!isBorderColorDefined(Spacing.START)) {
387+
colorStart = colorLeft;
388+
}
390389

391-
if (!isBorderColorDefined(Spacing.END)) {
392-
colorEnd = colorRight;
393-
}
390+
if (!isBorderColorDefined(Spacing.END)) {
391+
colorEnd = colorRight;
392+
}
393+
394+
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
395+
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;
396+
397+
colorLeft = directionAwareColorLeft;
398+
colorRight = directionAwareColorRight;
399+
} else {
400+
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
401+
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;
394402

395-
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
396-
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;
403+
final boolean isColorStartDefined = isBorderColorDefined(Spacing.START);
404+
final boolean isColorEndDefined = isBorderColorDefined(Spacing.END);
405+
final boolean isDirectionAwareColorLeftDefined =
406+
isRTL ? isColorEndDefined : isColorStartDefined;
407+
final boolean isDirectionAwareColorRightDefined =
408+
isRTL ? isColorStartDefined : isColorEndDefined;
397409

410+
if (isDirectionAwareColorLeftDefined) {
398411
colorLeft = directionAwareColorLeft;
412+
}
413+
414+
if (isDirectionAwareColorRightDefined) {
399415
colorRight = directionAwareColorRight;
400-
} else {
401-
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
402-
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;
403-
404-
final boolean isColorStartDefined = isBorderColorDefined(Spacing.START);
405-
final boolean isColorEndDefined = isBorderColorDefined(Spacing.END);
406-
final boolean isDirectionAwareColorLeftDefined =
407-
isRTL ? isColorEndDefined : isColorStartDefined;
408-
final boolean isDirectionAwareColorRightDefined =
409-
isRTL ? isColorStartDefined : isColorEndDefined;
410-
411-
if (isDirectionAwareColorLeftDefined) {
412-
colorLeft = directionAwareColorLeft;
413-
}
414-
415-
if (isDirectionAwareColorRightDefined) {
416-
colorRight = directionAwareColorRight;
417-
}
418416
}
419417
}
420418

@@ -1255,7 +1253,7 @@ public RectF getDirectionAwareBorderInsets() {
12551253
float borderLeftWidth = getBorderWidthOrDefaultTo(borderWidth, Spacing.LEFT);
12561254
float borderRightWidth = getBorderWidthOrDefaultTo(borderWidth, Spacing.RIGHT);
12571255

1258-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && mBorderWidth != null) {
1256+
if (mBorderWidth != null) {
12591257
final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
12601258
float borderStartWidth = mBorderWidth.getRaw(Spacing.START);
12611259
float borderEndWidth = mBorderWidth.getRaw(Spacing.END);

0 commit comments

Comments
 (0)