You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am adding LottieAnimationView to my layout inside ConstraintLayout. I have a one json file which is been keep in raw folder. Depending on the condition i am changing the layer index.
When I do this, I can see that the LottieAnimationView flickers.
`private suspend fun loadAndFilterData(
layerSet: Set,
viewAnimation: LottieAnimationView,
context: Context?
) {
withContext(Dispatchers.IO) {
try {
val inputStream: InputStream? =
context?.resources?.openRawResource(R.raw.animationjson)
val data = inputStream?.bufferedReader().use { it?.readText() }
val json = data?.let { JSONObject(it) }
// Get the layers and filter them based on the indices
val layers = json?.optJSONArray("layers") ?: JSONArray()
val newLayers = filterLayers(layers, layerSet)
// Replace the layers in the original JSON with the new filtered layers
json?.put("layers", newLayers)
// Now you would convert the modified JSON to a LottieAnimation
val animationVehicle = json.toString()
withContext(Dispatchers.Main) {
showAnimation(animationVehicle, viewAnimation)
}
} catch (e: IOException) {
DevLog.e("File Error", "Failed to read file")
} catch (e: Exception) {
DevLog.e("JSON Error", "Failed to parse or process JSON")
}
}
}
Hello Everyone,
I am adding LottieAnimationView to my layout inside ConstraintLayout. I have a one json file which is been keep in raw folder. Depending on the condition i am changing the layer index.
Like - loadData(setOf(32, 42, 44, 46, 48), binding.viewAnimation, context), loadData(setOf(0, 1, 13), binding.viewAnimation, context)
When I do this, I can see that the LottieAnimationView flickers.
`private suspend fun loadAndFilterData(
layerSet: Set,
viewAnimation: LottieAnimationView,
context: Context?
) {
withContext(Dispatchers.IO) {
try {
val inputStream: InputStream? =
context?.resources?.openRawResource(R.raw.animationjson)
val data = inputStream?.bufferedReader().use { it?.readText() }
val json = data?.let { JSONObject(it) }
// Get the layers and filter them based on the indices
val layers = json?.optJSONArray("layers") ?: JSONArray()
val newLayers = filterLayers(layers, layerSet)
// Replace the layers in the original JSON with the new filtered layers
json?.put("layers", newLayers)
// Now you would convert the modified JSON to a LottieAnimation
val animationVehicle = json.toString()
withContext(Dispatchers.Main) {
showAnimation(animationVehicle, viewAnimation)
}
} catch (e: IOException) {
DevLog.e("File Error", "Failed to read file")
} catch (e: Exception) {
DevLog.e("JSON Error", "Failed to parse or process JSON")
}
}
}
private fun showAnimation(
animationVehicle: String,
viewAnimation: LottieAnimationView
) {
viewAnimation.setAnimationFromJson(animationVehicle)
viewAnimation.speed = 1.0f
viewAnimation.playAnimation()
}`
is there a way to stop the flicker when layer is change. it should change smoothly without visible because in iOS it is happening smoothly.
The text was updated successfully, but these errors were encountered: