Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a LottieAnimationView overload for ZipInputStream #2411

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.PushbackInputStream;
import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipInputStream;

/**
* This view will load, deserialize, and display an After Effects animation exported with
Expand Down Expand Up @@ -508,6 +510,9 @@ public void setAnimationFromJson(String jsonString, @Nullable String cacheKey) {
* Sets the animation from an arbitrary InputStream.
* This will load and deserialize the file asynchronously.
* <p>
* If this is a Zip file, wrap your InputStream with a ZipInputStream to use the overload
* designed for zip files.
* <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.
* <p>
Expand All @@ -517,6 +522,19 @@ public void setAnimation(InputStream stream, @Nullable String cacheKey) {
setCompositionTask(LottieCompositionFactory.fromJsonInputStream(stream, cacheKey));
}

/**
* Sets the animation from a ZipInputStream.
* 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.
* <p>
* Auto-closes the stream.
*/
public void setAnimation(ZipInputStream stream, @Nullable String cacheKey) {
setCompositionTask(LottieCompositionFactory.fromZipStream(stream, cacheKey));
}

/**
* Load a lottie animation from a url. The url can be a json file or a zip file. Use a zip file if you have images. Simply zip them together and
* lottie
Expand Down