Skip to content

Commit 8a07a1a

Browse files
committed
[Focus Rings] Update FocusRingDrawable state copy constructor to do deep copy of shape appearance
PiperOrigin-RevId: 897093250
1 parent 8ecb378 commit 8a07a1a

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lib/java/com/google/android/material/focus/FocusRingDrawable.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import com.google.android.material.shape.ShapeAppearance;
5555
import com.google.android.material.shape.ShapeAppearanceModel;
5656
import com.google.android.material.shape.ShapeAppearancePathProvider;
57+
import com.google.android.material.shape.StateListShapeAppearanceModel;
5758
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5859
import java.io.IOException;
5960
import java.lang.ref.WeakReference;
@@ -910,9 +911,17 @@ private static final class FocusRingState extends ConstantState {
910911
this.ringInsetAttr = orig.ringInsetAttr;
911912
this.ringInnerInset = orig.ringInnerInset;
912913
this.ringInnerInsetAttr = orig.ringInnerInsetAttr;
913-
this.ringShapeAppearance = orig.ringShapeAppearance;
914914
this.ringShapeAppearanceResId = orig.ringShapeAppearanceResId;
915915
this.ringShapeAppearanceAttr = orig.ringShapeAppearanceAttr;
916+
if (orig.ringShapeAppearance instanceof ShapeAppearanceModel) {
917+
this.ringShapeAppearance =
918+
((ShapeAppearanceModel) orig.ringShapeAppearance).toBuilder().build();
919+
} else if (orig.ringShapeAppearance instanceof StateListShapeAppearanceModel) {
920+
this.ringShapeAppearance =
921+
((StateListShapeAppearanceModel) orig.ringShapeAppearance).toBuilder().build();
922+
} else {
923+
this.ringShapeAppearance = orig.ringShapeAppearance;
924+
}
916925
if (orig.ringCustomBounds != null) {
917926
this.ringCustomBounds = new Rect(orig.ringCustomBounds);
918927
}

0 commit comments

Comments
 (0)