Skip to content

Commit

Permalink
Add a LottieAnimationView overload for ZipInputStream (#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpeal committed Nov 3, 2023
1 parent 4c80588 commit 2ee2b28
Showing 1 changed file with 18 additions and 0 deletions.
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

0 comments on commit 2ee2b28

Please sign in to comment.