@@ -131,7 +131,7 @@ public class MaterialButtonGroup extends LinearLayout {
131131 @ Px private int spacing ;
132132 @ Nullable private StateListSizeChange buttonSizeChange ;
133133
134- private boolean isChildrenShapeInvalidated = true ;
134+ private boolean childShapesDirty = true ;
135135
136136 public MaterialButtonGroup (@ NonNull Context context ) {
137137 this (context , null );
@@ -209,7 +209,7 @@ public void addView(@NonNull View child, int index, @Nullable ViewGroup.LayoutPa
209209 // Recover the original layout params of all children before adding the new child.
210210 recoverAllChildrenLayoutParams ();
211211
212- isChildrenShapeInvalidated = true ;
212+ childShapesDirty = true ;
213213 super .addView (child , index , params );
214214 MaterialButton buttonChild = (MaterialButton ) child ;
215215 setGeneratedIdIfNeeded (buttonChild );
@@ -237,7 +237,7 @@ public void onViewRemoved(View child) {
237237 originalChildStateListShapeAppearanceModels .remove (indexOfChild );
238238 }
239239
240- isChildrenShapeInvalidated = true ;
240+ childShapesDirty = true ;
241241 updateChildShapes ();
242242
243243 // Recover the original layout params of all children before updating the child layout.
@@ -274,11 +274,10 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
274274 @ VisibleForTesting
275275 void updateChildShapes () {
276276 // No need to update shape if no inside corners or outer corners are specified.
277- if ((innerCornerSize == null && groupStateListShapeAppearance == null )
278- || !isChildrenShapeInvalidated ) {
277+ if ((innerCornerSize == null && groupStateListShapeAppearance == null ) || !childShapesDirty ) {
279278 return ;
280279 }
281- isChildrenShapeInvalidated = false ;
280+ childShapesDirty = false ;
282281 int childCount = getChildCount ();
283282 int firstVisibleChildIndex = getFirstVisibleChildIndex ();
284283 int lastVisibleChildIndex = getLastVisibleChildIndex ();
@@ -547,6 +546,14 @@ private int getButtonAllowedWidthIncrease(int index) {
547546
548547 // ================ Getters and setters ===================
549548
549+ @ Override
550+ public void setOrientation (int orientation ) {
551+ if (getOrientation () != orientation ) {
552+ childShapesDirty = true ;
553+ }
554+ super .setOrientation (orientation );
555+ }
556+
550557 /**
551558 * Returns the {@link StateListSizeChange} of child buttons on state changes.
552559 *
@@ -608,7 +615,7 @@ public CornerSize getInnerCornerSize() {
608615 */
609616 public void setInnerCornerSize (@ NonNull CornerSize cornerSize ) {
610617 innerCornerSize = StateListCornerSize .create (cornerSize );
611- isChildrenShapeInvalidated = true ;
618+ childShapesDirty = true ;
612619 updateChildShapes ();
613620 invalidate ();
614621 }
@@ -637,7 +644,7 @@ public StateListCornerSize getInnerCornerSizeStateList() {
637644 @ RestrictTo (Scope .LIBRARY_GROUP )
638645 public void setInnerCornerSizeStateList (@ NonNull StateListCornerSize cornerSizeStateList ) {
639646 innerCornerSize = cornerSizeStateList ;
640- isChildrenShapeInvalidated = true ;
647+ childShapesDirty = true ;
641648 updateChildShapes ();
642649 invalidate ();
643650 }
@@ -658,7 +665,7 @@ public ShapeAppearanceModel getShapeAppearance() {
658665 public void setShapeAppearance (@ Nullable ShapeAppearanceModel shapeAppearance ) {
659666 groupStateListShapeAppearance =
660667 new StateListShapeAppearanceModel .Builder (shapeAppearance ).build ();
661- isChildrenShapeInvalidated = true ;
668+ childShapesDirty = true ;
662669 updateChildShapes ();
663670 invalidate ();
664671 }
@@ -684,7 +691,7 @@ public StateListShapeAppearanceModel getStateListShapeAppearance() {
684691 public void setStateListShapeAppearance (
685692 @ Nullable StateListShapeAppearanceModel stateListShapeAppearance ) {
686693 groupStateListShapeAppearance = stateListShapeAppearance ;
687- isChildrenShapeInvalidated = true ;
694+ childShapesDirty = true ;
688695 updateChildShapes ();
689696 invalidate ();
690697 }
0 commit comments