I am using lottie to show some animation while screen design. But while designing lottie is freezed. I am using the following code for get lottie image.
@NonNull
public static LottieDrawable getLottieFromInputStream(@NonNull InputStream inputStream) {
LottieComposition composition = LottieCompositionFactory.fromJsonInputStreamSync(inputStream, null).getValue();
LottieDrawable mLottieDrawable = new LottieDrawable();
mLottieDrawable.enableMergePathsForKitKatAndAbove(true);
mLottieDrawable.setComposition(composition);
mLottieDrawable.playAnimation();
return mLottieDrawable;
}
And set the layout background like:
Drawable drawableImage = getLottieFromInputStream(pContext.getAssets().open(pImageName));
layout.setBackground(drawableImage);
It is animation when background request is happaning. But when after received response we designing the screen. When screen designing in background the lottie is freezed. Is there any way to run the lottie in worker thread?
here's code that avoid freezing lottie animation:
and here's an example of how you call the function: