Skip to content

Commit a87e102

Browse files
pekingmedsn5ft
authored andcommitted
[ButtonGroup] Remove unnecessary layout param recovery in MaterialButtonGroup.
The call to recoverAllChildrenLayoutParams() in onLayout is not required and can be removed. Resolves #5034 PiperOrigin-RevId: 894235853
1 parent e6f6bd3 commit a87e102

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

lib/java/com/google/android/material/button/MaterialButton.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
589589
int curOrientation = getResources().getConfiguration().orientation;
590590
if (orientation != curOrientation) {
591591
orientation = curOrientation;
592-
originalWidth = UNSET;
592+
recoverOriginalLayoutParams();
593593
}
594594
if (originalWidth == UNSET) {
595595
originalWidth = getMeasuredWidth();
@@ -634,7 +634,7 @@ void recoverOriginalLayoutParams() {
634634

635635
@Override
636636
public void setWidth(@Px int pixels) {
637-
originalWidth = UNSET;
637+
recoverOriginalLayoutParams();
638638
super.setWidth(pixels);
639639
}
640640

@@ -679,19 +679,19 @@ public void refreshDrawableState() {
679679

680680
@Override
681681
public void setText(CharSequence text, BufferType type) {
682-
originalWidth = UNSET;
682+
recoverOriginalLayoutParams();
683683
super.setText(text, type);
684684
}
685685

686686
@Override
687687
public void setTextAppearance(Context context, int resId) {
688-
originalWidth = UNSET;
688+
recoverOriginalLayoutParams();
689689
super.setTextAppearance(context, resId);
690690
}
691691

692692
@Override
693693
public void setTextSize(int unit, float size) {
694-
originalWidth = UNSET;
694+
recoverOriginalLayoutParams();
695695
super.setTextSize(unit, size);
696696
}
697697

@@ -910,7 +910,7 @@ void setInternalBackground(Drawable background) {
910910
@Override
911911
public void setCompoundDrawablePadding(@Px int padding) {
912912
if (getCompoundDrawablePadding() != padding) {
913-
originalWidth = UNSET;
913+
recoverOriginalLayoutParams();
914914
}
915915
super.setCompoundDrawablePadding(padding);
916916
}
@@ -958,7 +958,7 @@ public void setIconSize(@Px int iconSize) {
958958
if (maybeRunAfterWidthAnimation(() -> setIconSize(iconSize))) {
959959
return;
960960
}
961-
originalWidth = UNSET;
961+
recoverOriginalLayoutParams();
962962
this.iconSize = iconSize;
963963
updateIcon(/* needsIconReset= */ true);
964964
updateSecondaryIcon(/* needsIconReset= */ true);
@@ -991,7 +991,7 @@ public void setIcon(@Nullable Drawable icon) {
991991
if (maybeRunAfterWidthAnimation(() -> setIcon(icon))) {
992992
return;
993993
}
994-
originalWidth = UNSET;
994+
recoverOriginalLayoutParams();
995995
this.icon = icon;
996996
updateIcon(/* needsIconReset= */ true);
997997
updateIconPosition(getMeasuredWidth(), getMeasuredHeight());
@@ -1106,7 +1106,7 @@ public void setSecondaryIcon(@Nullable Drawable icon) {
11061106
if (maybeRunAfterWidthAnimation(() -> setIcon(icon))) {
11071107
return;
11081108
}
1109-
originalWidth = UNSET;
1109+
recoverOriginalLayoutParams();
11101110
secondaryIcon = icon;
11111111
stopNullSecondaryIconUpdate = false;
11121112
updateSecondaryIcon(/* needsIconReset= */ true);

lib/java/com/google/android/material/button/MaterialButtonGroup.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
400400
protected void onLayout(boolean changed, int l, int t, int r, int b) {
401401
super.onLayout(changed, l, t, r, b);
402402
if (changed) {
403-
recoverAllChildrenLayoutParams();
404403
adjustChildSizeChange();
405404
}
406405
}

0 commit comments

Comments
 (0)