Remove null restriction on value callbacks (#675)
This prevented you from clearing a ColorFilter
Fixes #638
diff --git a/LottieSample/src/androidTest/java/com/airbnb/lottie/LottieSnapshotProvider.java b/LottieSample/src/androidTest/java/com/airbnb/lottie/LottieSnapshotProvider.java
index 585baf5..6137161 100644
--- a/LottieSample/src/androidTest/java/com/airbnb/lottie/LottieSnapshotProvider.java
+++ b/LottieSample/src/androidTest/java/com/airbnb/lottie/LottieSnapshotProvider.java
@@ -434,6 +434,12 @@
new LottieValueCallback<ColorFilter>(new SimpleColorFilter(Color.GREEN)));
testDynamicProperty(
+ "Null Color Filter",
+ new KeyPath("**"),
+ LottieProperty.COLOR_FILTER,
+ new LottieValueCallback<ColorFilter>(null));
+
+ testDynamicProperty(
"Opacity interpolation (0)",
new KeyPath("Shape Layer 1", "Rectangle"),
LottieProperty.TRANSFORM_OPACITY,
diff --git a/lottie/src/main/java/com/airbnb/lottie/value/LottieValueCallback.java b/lottie/src/main/java/com/airbnb/lottie/value/LottieValueCallback.java
index 883f5cd..54ca604 100644
--- a/lottie/src/main/java/com/airbnb/lottie/value/LottieValueCallback.java
+++ b/lottie/src/main/java/com/airbnb/lottie/value/LottieValueCallback.java
@@ -1,7 +1,6 @@
package com.airbnb.lottie.value;
-import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
@@ -24,7 +23,7 @@
public LottieValueCallback() {
}
- public LottieValueCallback(@NonNull T staticValue) {
+ public LottieValueCallback(@Nullable T staticValue) {
value = staticValue;
}
@@ -32,10 +31,6 @@
* Override this if you haven't set a static value in the constructor or with setValue.
*/
public T getValue(LottieFrameInfo<T> frameInfo) {
- if (value == null) {
- throw new IllegalArgumentException("You must provide a static value in the constructor " +
- ", call setValue, or override getValue.");
- }
return value;
}