Added an api to create a composition without closing the InputStream
@@ -232,14 +232,21 @@ public class LottieComposition {
@Nullable
public static LottieComposition fromInputStreamSync(InputStream stream) {
+ return fromInputStreamSync(stream, true);
+ }
+
+ @Nullable
+ public static LottieComposition fromInputStreamSync(InputStream stream, boolean close) {
LottieComposition composition;
try {
composition = fromJsonSync(new JsonReader(new InputStreamReader(stream)));
} catch (IOException e) {
throw new IllegalArgumentException("Unable to parse composition.", e);
} finally {
+ if (close) {
closeQuietly(stream);
}
+ }
return composition;
}
