Skip to content

Commit

Permalink
Add close param to LottieCompositionFactory.fromJsonReader (#2342)
Browse files Browse the repository at this point in the history
  • Loading branch information
peerless2012 committed Jul 25, 2023
1 parent 6c26b9f commit 78dd109
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,22 +333,14 @@ public static LottieResult<LottieComposition> fromJsonInputStreamSync(InputStrea
return fromJsonInputStreamSync(stream, cacheKey, true);
}


/**
* Return a LottieComposition for the given InputStream to json.
*/
@WorkerThread
public static LottieResult<LottieComposition> fromJsonInputStreamSync(InputStream stream, @Nullable String cacheKey, boolean close) {
try {
return fromJsonReaderSync(JsonReader.of(buffer(source(stream))), cacheKey);
} finally {
if (close) {
closeQuietly(stream);
}
}
return fromJsonReaderSync(JsonReader.of(buffer(source(stream))), cacheKey, close);
}


/**
* @see #fromJsonSync(JSONObject, String)
*/
Expand Down Expand Up @@ -394,12 +386,15 @@ public static LottieTask<LottieComposition> fromJsonReader(final JsonReader read
return cache(cacheKey, () -> fromJsonReaderSync(reader, cacheKey), () -> Utils.closeQuietly(reader));
}


@WorkerThread
public static LottieResult<LottieComposition> fromJsonReaderSync(com.airbnb.lottie.parser.moshi.JsonReader reader, @Nullable String cacheKey) {
return fromJsonReaderSyncInternal(reader, cacheKey, true);
return fromJsonReaderSync(reader, cacheKey, true);
}

@WorkerThread
public static LottieResult<LottieComposition> fromJsonReaderSync(com.airbnb.lottie.parser.moshi.JsonReader reader, @Nullable String cacheKey, boolean close) {
return fromJsonReaderSyncInternal(reader, cacheKey, close);
}

private static LottieResult<LottieComposition> fromJsonReaderSyncInternal(
com.airbnb.lottie.parser.moshi.JsonReader reader, @Nullable String cacheKey, boolean close) {
Expand Down

0 comments on commit 78dd109

Please sign in to comment.