From d9c853aadc7f0e911db9874338e0dead3a224a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=BF=90=E6=9E=97?= Date: Thu, 25 Apr 2024 09:03:51 +0800 Subject: [PATCH] Fix blinking issue when loop the animation in minFrame and maxFrame --- .../lottie/utils/LottieValueAnimator.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lottie/src/main/java/com/airbnb/lottie/utils/LottieValueAnimator.java b/lottie/src/main/java/com/airbnb/lottie/utils/LottieValueAnimator.java index a5fff5a64f..10d90eeffa 100644 --- a/lottie/src/main/java/com/airbnb/lottie/utils/LottieValueAnimator.java +++ b/lottie/src/main/java/com/airbnb/lottie/utils/LottieValueAnimator.java @@ -105,18 +105,14 @@ public void setUseCompositionFrameRate(boolean useCompositionFrameRate) { lastFrameTimeNs = frameTimeNanos; - if (!useCompositionFrameRate || frameRaw != previousFrameRaw) { - notifyUpdate(); - } if (ended) { if (getRepeatCount() != INFINITE && repeatCount >= getRepeatCount()) { frameRaw = speed < 0 ? getMinFrame() : getMaxFrame(); frame = frameRaw; removeFrameCallback(); + checkNotifyUpdate(previousFrameRaw); notifyEnd(isReversed()); } else { - notifyRepeat(); - repeatCount++; if (getRepeatMode() == REVERSE) { speedReversedForRepeatMode = !speedReversedForRepeatMode; reverseAnimationSpeed(); @@ -125,7 +121,12 @@ public void setUseCompositionFrameRate(boolean useCompositionFrameRate) { frame = frameRaw; } lastFrameTimeNs = frameTimeNanos; + checkNotifyUpdate(previousFrameRaw); + notifyRepeat(); + repeatCount++; } + } else { + checkNotifyUpdate(previousFrameRaw); } verifyFrame(); @@ -134,6 +135,12 @@ public void setUseCompositionFrameRate(boolean useCompositionFrameRate) { } } + private void checkNotifyUpdate(float previousFrameRaw) { + if (!useCompositionFrameRate || frameRaw != previousFrameRaw) { + notifyUpdate(); + } + } + private float getFrameDurationNs() { if (composition == null) { return Float.MAX_VALUE;