Replace LottieAnimiationView JsonReader API with just InputStream and hide visibility of the Lottie Moshi JSON parsing classes. (#1279)
This PR also hides the visibility of the Lottie Moshi JSON parsing classes.
Fixes #1270
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
index ad70a4b..421abcb 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
@@ -32,6 +32,7 @@
import com.airbnb.lottie.value.SimpleLottieValueCallback;
import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import java.io.StringReader;
import java.util.HashSet;
import java.util.List;
@@ -346,18 +347,18 @@
* JSONObject never has to be done.
*/
public void setAnimationFromJson(String jsonString, @Nullable String cacheKey) {
- setAnimation(JsonReader.of(Okio.buffer(Okio.source(new ByteArrayInputStream(jsonString.getBytes())))), cacheKey);
+ setAnimation(new ByteArrayInputStream(jsonString.getBytes()), cacheKey);
}
/**
- * Sets the animation from a JSONReader.
+ * Sets the animation from an arbitrary InputStream.
* This will load and deserialize the file asynchronously.
* <p>
* This is particularly useful for animations loaded from the network. You can fetch the
* bodymovin json from the network and pass it directly here.
*/
- public void setAnimation(JsonReader reader, @Nullable String cacheKey) {
- setCompositionTask(LottieCompositionFactory.fromJsonReader(reader, cacheKey));
+ public void setAnimation(InputStream stream, @Nullable String cacheKey) {
+ setCompositionTask(LottieCompositionFactory.fromJsonInputStream(stream, cacheKey));
}
/**
diff --git a/lottie/src/main/java/com/airbnb/lottie/parser/moshi/package-info.java b/lottie/src/main/java/com/airbnb/lottie/parser/moshi/package-info.java
new file mode 100644
index 0000000..3c6cd55
--- /dev/null
+++ b/lottie/src/main/java/com/airbnb/lottie/parser/moshi/package-info.java
@@ -0,0 +1,6 @@
+@RestrictTo(LIBRARY)
+package com.airbnb.lottie.parser.moshi;
+
+import androidx.annotation.RestrictTo;
+
+import static androidx.annotation.RestrictTo.Scope.LIBRARY;
\ No newline at end of file