Hi,
I have got a view like this:
<com.lottiefiles.dotlottie.core.widget.DotLottieAnimation
android:id="@+id/lottie_question"
android:layout_width="70dp"
android:layout_height="70dp"
app:dotLottie_autoplay="true"
app:dotLottie_loop="false"
app:dotLottie_src="question.json"
app:dotLottie_useFrameInterpolation="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
When the animation finishes, it disappears. I have tried the following code:
DotLottieAnimation anim = exitDialog.findViewById(R.id.lottie_question);
anim.addEventListener(new DotLottieEventListener() {
@Override
public void onComplete() {
anim.setFrame(anim.getTotalFrames());
}
});
However, my app freezes completely and I get the following error:
ANR in com.xyz.ang (com.xyz.ang/.activity.learning.QuizActivity)
PID: 18191
Reason: Input dispatching timed out (674e807 com.xyz.ang/com.xyz.ang.activity.learning.QuizActivity (server) is not responding. Waited 10000ms for MotionEvent).
After many attempts, I ended up using the freeze() function, which works exactly as I wanted.
@Override
public void onComplete() {
anim.post(anim::freeze);
}
Is there a simpler way to make the animation stay on the last frame after finishing, instead of having to use addEventListener(new DotLottieEventListener() { ... })?
I am using 0.12.0 version.