diff --git a/lottie/src/main/java/com/airbnb/lottie/model/layer/SolidLayer.java b/lottie/src/main/java/com/airbnb/lottie/model/layer/SolidLayer.java index 65ae32c126..19e7d53bd3 100644 --- a/lottie/src/main/java/com/airbnb/lottie/model/layer/SolidLayer.java +++ b/lottie/src/main/java/com/airbnb/lottie/model/layer/SolidLayer.java @@ -18,6 +18,7 @@ import com.airbnb.lottie.value.LottieValueCallback; public class SolidLayer extends BaseLayer { + private final RectF rect = new RectF(); private final Paint paint = new LPaint(); private final float[] points = new float[8]; @@ -41,12 +42,17 @@ public class SolidLayer extends BaseLayer { return; } + Integer color = colorAnimation == null ? null : colorAnimation.getValue(); + if (color != null) { + paint.setColor(color); + } else { + paint.setColor(layerModel.getSolidColor()); + } + int opacity = transform.getOpacity() == null ? 100 : transform.getOpacity().getValue(); int alpha = (int) (parentAlpha / 255f * (backgroundAlpha / 255f * opacity / 100f) * 255); paint.setAlpha(alpha); - if (colorAnimation != null) { - paint.setColor(colorAnimation.getValue()); - } + if (colorFilterAnimation != null) { paint.setColorFilter(colorFilterAnimation.getValue()); } diff --git a/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/DynamicPropertiesTestCase.kt b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/DynamicPropertiesTestCase.kt index 407e3ea105..5a779de683 100644 --- a/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/DynamicPropertiesTestCase.kt +++ b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/DynamicPropertiesTestCase.kt @@ -385,6 +385,14 @@ class DynamicPropertiesTestCase : SnapshotTestCase { assetName = "Tests/SolidLayerTransform.json" ) + testDynamicProperty( + "Solid Color w/ null", + KeyPath("Cyan Solid 1", "**"), + LottieProperty.COLOR, + LottieValueCallback(null), + assetName = "Tests/SolidLayerTransform.json" + ) + withDrawable("Tests/DynamicGradient.json", "Gradient Colors", "Linear Gradient Fill") { drawable -> val value = object : LottieValueCallback>() { override fun getValue(frameInfo: LottieFrameInfo>?): Array {