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

fix: dot lottie for android in release mode #1091

Merged
merged 1 commit into from
Aug 16, 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.airbnb.lottie.SimpleColorFilter
import com.airbnb.lottie.TextDelegate
import com.airbnb.lottie.model.KeyPath
import com.airbnb.lottie.value.LottieValueCallback
import com.facebook.react.BuildConfig
import com.facebook.react.bridge.ColorPropConverter
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
Expand Down Expand Up @@ -94,9 +95,27 @@ class LottieAnimationViewPropertyManager(view: LottieAnimationView) {
animationURL = null
}

sourceDotLottie?.let {
view.setAnimationFromUrl(it, it.hashCode().toString())
sourceDotLottie = null
sourceDotLottie?.let { assetName ->
if(BuildConfig.DEBUG) {
view.setAnimationFromUrl(assetName)
sourceDotLottie = null
return
}

// resource needs to be loaded in release mode: https://github.com/facebook/react-native/issues/24963#issuecomment-532168307
val resourceId = view.resources.getIdentifier(
assetName,
"raw",
view.context.packageName
)

if (resourceId == 0) {
RNLog.e("Animation for $assetName was not found in raw resources")
return
}

view.setAnimation(resourceId)
animationNameDirty = false
}

if (animationNameDirty) {
Expand Down