@@ -174,7 +174,7 @@ public class MaterialButtonGroup extends LinearLayout {
174
174
@ Px private int spacing ;
175
175
@ Nullable private StateListSizeChange buttonSizeChange ;
176
176
177
- private boolean isChildrenShapeInvalidated = true ;
177
+ private boolean childShapesDirty = true ;
178
178
179
179
private final int overflowMenuItemIconPadding ;
180
180
private boolean buttonOverflowInitialized ;
@@ -305,7 +305,7 @@ public void addView(@NonNull View child, int index, @Nullable ViewGroup.LayoutPa
305
305
306
306
// Recover the original layout params of all children before adding the new child.
307
307
recoverAllChildrenLayoutParams ();
308
- isChildrenShapeInvalidated = true ;
308
+ childShapesDirty = true ;
309
309
// If overflow button has been added, the new child button will be always added before the
310
310
// overflow button.
311
311
int overflowButtonIndex = indexOfChild (overflowButton );
@@ -340,7 +340,7 @@ public void onViewRemoved(View child) {
340
340
originalChildStateListShapeAppearanceModels .remove (indexOfChild );
341
341
}
342
342
343
- isChildrenShapeInvalidated = true ;
343
+ childShapesDirty = true ;
344
344
updateChildShapes ();
345
345
346
346
// Recover the original layout params of all children before updating the child layout.
@@ -517,11 +517,10 @@ private void updateOverflowMenuItemsState() {
517
517
@ VisibleForTesting
518
518
void updateChildShapes () {
519
519
// No need to update shape if no inside corners or outer corners are specified.
520
- if ((innerCornerSize == null && groupStateListShapeAppearance == null )
521
- || !isChildrenShapeInvalidated ) {
520
+ if ((innerCornerSize == null && groupStateListShapeAppearance == null ) || !childShapesDirty ) {
522
521
return ;
523
522
}
524
- isChildrenShapeInvalidated = false ;
523
+ childShapesDirty = false ;
525
524
int childCount = getChildCount ();
526
525
int firstVisibleChildIndex = getFirstVisibleChildIndex ();
527
526
int lastVisibleChildIndex = getLastVisibleChildIndex ();
@@ -790,6 +789,14 @@ private int getButtonAllowedWidthIncrease(int index) {
790
789
791
790
// ================ Getters and setters ===================
792
791
792
+ @ Override
793
+ public void setOrientation (int orientation ) {
794
+ if (getOrientation () != orientation ) {
795
+ childShapesDirty = true ;
796
+ }
797
+ super .setOrientation (orientation );
798
+ }
799
+
793
800
/**
794
801
* Returns the {@link StateListSizeChange} of child buttons on state changes.
795
802
*
@@ -851,7 +858,7 @@ public CornerSize getInnerCornerSize() {
851
858
*/
852
859
public void setInnerCornerSize (@ NonNull CornerSize cornerSize ) {
853
860
innerCornerSize = StateListCornerSize .create (cornerSize );
854
- isChildrenShapeInvalidated = true ;
861
+ childShapesDirty = true ;
855
862
updateChildShapes ();
856
863
invalidate ();
857
864
}
@@ -880,7 +887,7 @@ public StateListCornerSize getInnerCornerSizeStateList() {
880
887
@ RestrictTo (Scope .LIBRARY_GROUP )
881
888
public void setInnerCornerSizeStateList (@ NonNull StateListCornerSize cornerSizeStateList ) {
882
889
innerCornerSize = cornerSizeStateList ;
883
- isChildrenShapeInvalidated = true ;
890
+ childShapesDirty = true ;
884
891
updateChildShapes ();
885
892
invalidate ();
886
893
}
@@ -901,7 +908,7 @@ public ShapeAppearanceModel getShapeAppearance() {
901
908
public void setShapeAppearance (@ Nullable ShapeAppearanceModel shapeAppearance ) {
902
909
groupStateListShapeAppearance =
903
910
new StateListShapeAppearanceModel .Builder (shapeAppearance ).build ();
904
- isChildrenShapeInvalidated = true ;
911
+ childShapesDirty = true ;
905
912
updateChildShapes ();
906
913
invalidate ();
907
914
}
@@ -927,7 +934,7 @@ public StateListShapeAppearanceModel getStateListShapeAppearance() {
927
934
public void setStateListShapeAppearance (
928
935
@ Nullable StateListShapeAppearanceModel stateListShapeAppearance ) {
929
936
groupStateListShapeAppearance = stateListShapeAppearance ;
930
- isChildrenShapeInvalidated = true ;
937
+ childShapesDirty = true ;
931
938
updateChildShapes ();
932
939
invalidate ();
933
940
}
@@ -1137,8 +1144,7 @@ public LayoutParams(@NonNull Context context, @Nullable AttributeSet attrs) {
1137
1144
1138
1145
overflowIcon =
1139
1146
attributes .getDrawable (R .styleable .MaterialButtonGroup_Layout_layout_overflowIcon );
1140
- overflowText =
1141
- attributes .getText (R .styleable .MaterialButtonGroup_Layout_layout_overflowText );
1147
+ overflowText = attributes .getText (R .styleable .MaterialButtonGroup_Layout_layout_overflowText );
1142
1148
1143
1149
attributes .recycle ();
1144
1150
}
@@ -1199,8 +1205,8 @@ public LayoutParams(@NonNull MaterialButtonGroup.LayoutParams source) {
1199
1205
}
1200
1206
1201
1207
/**
1202
- * Class for common logic between this MaterialButtonGroup and the OverflowLinearLayout
1203
- * overflow features.
1208
+ * Class for common logic between this MaterialButtonGroup and the OverflowLinearLayout overflow
1209
+ * features.
1204
1210
*
1205
1211
* @hide
1206
1212
*/
0 commit comments