@@ -131,7 +131,7 @@ public class MaterialButtonGroup extends LinearLayout {
131
131
@ Px private int spacing ;
132
132
@ Nullable private StateListSizeChange buttonSizeChange ;
133
133
134
- private boolean isChildrenShapeInvalidated = true ;
134
+ private boolean childShapesDirty = true ;
135
135
136
136
public MaterialButtonGroup (@ NonNull Context context ) {
137
137
this (context , null );
@@ -209,7 +209,7 @@ public void addView(@NonNull View child, int index, @Nullable ViewGroup.LayoutPa
209
209
// Recover the original layout params of all children before adding the new child.
210
210
recoverAllChildrenLayoutParams ();
211
211
212
- isChildrenShapeInvalidated = true ;
212
+ childShapesDirty = true ;
213
213
super .addView (child , index , params );
214
214
MaterialButton buttonChild = (MaterialButton ) child ;
215
215
setGeneratedIdIfNeeded (buttonChild );
@@ -237,7 +237,7 @@ public void onViewRemoved(View child) {
237
237
originalChildStateListShapeAppearanceModels .remove (indexOfChild );
238
238
}
239
239
240
- isChildrenShapeInvalidated = true ;
240
+ childShapesDirty = true ;
241
241
updateChildShapes ();
242
242
243
243
// 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) {
274
274
@ VisibleForTesting
275
275
void updateChildShapes () {
276
276
// 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 ) {
279
278
return ;
280
279
}
281
- isChildrenShapeInvalidated = false ;
280
+ childShapesDirty = false ;
282
281
int childCount = getChildCount ();
283
282
int firstVisibleChildIndex = getFirstVisibleChildIndex ();
284
283
int lastVisibleChildIndex = getLastVisibleChildIndex ();
@@ -547,6 +546,14 @@ private int getButtonAllowedWidthIncrease(int index) {
547
546
548
547
// ================ Getters and setters ===================
549
548
549
+ @ Override
550
+ public void setOrientation (int orientation ) {
551
+ if (getOrientation () != orientation ) {
552
+ childShapesDirty = true ;
553
+ }
554
+ super .setOrientation (orientation );
555
+ }
556
+
550
557
/**
551
558
* Returns the {@link StateListSizeChange} of child buttons on state changes.
552
559
*
@@ -608,7 +615,7 @@ public CornerSize getInnerCornerSize() {
608
615
*/
609
616
public void setInnerCornerSize (@ NonNull CornerSize cornerSize ) {
610
617
innerCornerSize = StateListCornerSize .create (cornerSize );
611
- isChildrenShapeInvalidated = true ;
618
+ childShapesDirty = true ;
612
619
updateChildShapes ();
613
620
invalidate ();
614
621
}
@@ -637,7 +644,7 @@ public StateListCornerSize getInnerCornerSizeStateList() {
637
644
@ RestrictTo (Scope .LIBRARY_GROUP )
638
645
public void setInnerCornerSizeStateList (@ NonNull StateListCornerSize cornerSizeStateList ) {
639
646
innerCornerSize = cornerSizeStateList ;
640
- isChildrenShapeInvalidated = true ;
647
+ childShapesDirty = true ;
641
648
updateChildShapes ();
642
649
invalidate ();
643
650
}
@@ -658,7 +665,7 @@ public ShapeAppearanceModel getShapeAppearance() {
658
665
public void setShapeAppearance (@ Nullable ShapeAppearanceModel shapeAppearance ) {
659
666
groupStateListShapeAppearance =
660
667
new StateListShapeAppearanceModel .Builder (shapeAppearance ).build ();
661
- isChildrenShapeInvalidated = true ;
668
+ childShapesDirty = true ;
662
669
updateChildShapes ();
663
670
invalidate ();
664
671
}
@@ -684,7 +691,7 @@ public StateListShapeAppearanceModel getStateListShapeAppearance() {
684
691
public void setStateListShapeAppearance (
685
692
@ Nullable StateListShapeAppearanceModel stateListShapeAppearance ) {
686
693
groupStateListShapeAppearance = stateListShapeAppearance ;
687
- isChildrenShapeInvalidated = true ;
694
+ childShapesDirty = true ;
688
695
updateChildShapes ();
689
696
invalidate ();
690
697
}
0 commit comments