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

[Compose] Make LottieCompositionSpec an inline class #1855

Merged
merged 1 commit into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
}
dependencies {
classpath 'org.ajoberstar:grgit:1.9.3'
classpath 'com.android.tools.build:gradle:7.0.0-beta05'
classpath 'com.android.tools.build:gradle:7.0.0-rc01'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'org.ajoberstar:grgit:1.9.3'
classpath "net.ltgt.gradle:gradle-errorprone-plugin:2.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ package com.airbnb.lottie.compose
* A [com.airbnb.lottie.LottieComposition] is the stateless parsed version of a Lottie json file and is
* passed into [rememberLottieComposition] or [LottieAnimation].
*/
sealed class LottieCompositionSpec {
sealed interface LottieCompositionSpec {

/**
* Load an animation from res/raw.
*/
data class RawRes(@androidx.annotation.RawRes val resId: Int) : LottieCompositionSpec()
inline class RawRes(@androidx.annotation.RawRes val resId: Int) : LottieCompositionSpec

/**
* Load an animation from the internet. Lottie has a default network stack that will use
Expand All @@ -23,22 +23,22 @@ sealed class LottieCompositionSpec {
* passing this spec directly into [LottieAnimation] because it can fail and you want to
* make sure that you properly handle the failures and/or retries.
*/
data class Url(val url: String) : LottieCompositionSpec()
inline class Url(val url: String) : LottieCompositionSpec

/**
* Load an animation from an arbitrary file. Make sure that your app has permissions to read it
* or else this may fail.
*/
data class File(val fileName: String) : LottieCompositionSpec()
inline class File(val fileName: String) : LottieCompositionSpec

/**
* Load an animation from the assets directory of your app. This isn't type safe like [RawRes]
* so make sure that the path to your animation is correct this will fail.
*/
data class Asset(val assetName: String) : LottieCompositionSpec()
inline class Asset(val assetName: String) : LottieCompositionSpec

/**
* Load an animation from its json string.
*/
data class JsonString(val jsonString: String) : LottieCompositionSpec()
}
inline class JsonString(val jsonString: String) : LottieCompositionSpec
}