@@ -186,6 +186,7 @@ public CornerSize apply(@NonNull CornerSize cornerSize) {
186186
187187 // Variables for corner morph.
188188 private boolean boundsIsEmpty = true ;
189+ private boolean isRoundRectCornerMorph = true ;
189190 @ NonNull private ShapeAppearanceModel strokeShapeAppearanceModel ;
190191 @ Nullable private SpringForce cornerSpringForce ;
191192 @ NonNull SpringAnimation [] cornerSpringAnimations = new SpringAnimation [NUM_CORNERS ];
@@ -1346,10 +1347,8 @@ private float calculateRoundRectCornerSize(
13461347 // a round rect, use the top left corner size for drawing the round rect.
13471348 return shapeAppearanceModel .getTopLeftCornerSize ().getCornerSize (bounds );
13481349 }
1349- } else if (areAllElementsEqual (cornerSizeOverrides )
1350- && shapeAppearanceModel .hasRoundedCorners ()) {
1351- // If there are corner size overrides and they're all the same, use the first one for drawing
1352- // the round rect.
1350+ } else if (isRoundRectCornerMorph ) {
1351+ // If the shape being morphed is a round rect, use the first one for drawing the round rect.
13531352 return cornerSizeOverrides [0 ];
13541353 }
13551354 // Returns a negative corner size to indicate the current shape cannot be drawn as a round rect.
@@ -1568,6 +1567,9 @@ private void updateShape(int[] state, boolean skipAnimation) {
15681567 }
15691568 ShapeAppearanceModel shapeAppearanceModel =
15701569 drawableState .shapeAppearance .getShapeForState (state );
1570+ if (areAllElementsEqual (springAnimatedCornerSizes )){
1571+ isRoundRectCornerMorph = shapeAppearanceModel .isRoundRect (getBoundsAsRectF ());
1572+ }
15711573 for (int i = 0 ; i < NUM_CORNERS ; i ++) {
15721574 float targetCornerSize =
15731575 pathProvider .getCornerSizeForIndex (i , shapeAppearanceModel ).getCornerSize (bounds );
@@ -1676,11 +1678,9 @@ public float getBottomRightCornerResolvedSize() {
16761678 @ RestrictTo (LIBRARY_GROUP )
16771679 public boolean isRoundRect () {
16781680 ShapeAppearanceModel shapeAppearanceModel =
1679- drawableState .shapeAppearance .getDefaultShape ( );
1681+ drawableState .shapeAppearance .getShapeForState ( getState () );
16801682 return shapeAppearanceModel .isRoundRect (getBoundsAsRectF ())
1681- || (springAnimatedCornerSizes != null
1682- && areAllElementsEqual (springAnimatedCornerSizes )
1683- && shapeAppearanceModel .hasRoundedCorners ());
1683+ && (springAnimatedCornerSizes == null || isRoundRectCornerMorph );
16841684 }
16851685
16861686 /**
0 commit comments