1 package com.airbnb.lottie.compose 2 3 import android.net.Uri 4 5 /** 6 * Specification for a [com.airbnb.lottie.LottieComposition]. Each subclass represents a different source. 7 * A [com.airbnb.lottie.LottieComposition] is the stateless parsed version of a Lottie json file and is 8 * passed into [rememberLottieComposition] or [LottieAnimation]. 9 */ 10 sealed interface LottieCompositionSpec { 11 12 /** 13 * Load an animation from res/raw. 14 */ 15 @JvmInline 16 value class RawRes(@androidx.annotation.RawRes val resId: Int) : LottieCompositionSpec 17 18 /** 19 * Load an animation from the internet. Lottie has a default network stack that will use 20 * standard Android networking APIs to attempt to load your animation. You may want to 21 * integrate your own networking stack instead for consistency, to add your own headers, 22 * or implement retries. To do that, call [com.airbnb.lottie.Lottie.initialize] and set 23 * a [com.airbnb.lottie.network.LottieNetworkFetcher] on the [com.airbnb.lottie.LottieConfig]. 24 * 25 * If you are using this spec, you may want to use [rememberLottieComposition] instead of 26 * passing this spec directly into [LottieAnimation] because it can fail and you want to 27 * make sure that you properly handle the failures and/or retries. 28 */ 29 @JvmInline 30 value class Url(val url: String) : LottieCompositionSpec 31 32 /** 33 * Load an animation from an arbitrary file. Make sure that your app has permissions to read it 34 * or else this may fail. 35 */ 36 @JvmInline 37 value class File(val fileName: String) : LottieCompositionSpec 38 39 /** 40 * Load an animation from the assets directory of your app. This isn't type safe like [RawRes] 41 * so make sure that the path to your animation is correct this will fail. 42 */ 43 @JvmInline 44 value class Asset(val assetName: String) : LottieCompositionSpec 45 46 /** 47 * Load an animation from its json string. 48 */ 49 @JvmInline 50 value class JsonString(val jsonString: String) : LottieCompositionSpec 51 52 /** 53 * Load an animation from a content provider URI. 54 */ 55 @JvmInline 56 value class ContentProvider(val uri: Uri) : LottieCompositionSpec 57 } 58