Skip to content

Commit

Permalink
Fix blinking issue when loop the animation in minFrame and maxFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
yunlinos committed Apr 25, 2024
1 parent aebf9bc commit d9c853a
Showing 1 changed file with 12 additions and 5 deletions.
Expand Up @@ -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();
Expand All @@ -125,7 +121,12 @@ public void setUseCompositionFrameRate(boolean useCompositionFrameRate) {
frame = frameRaw;
}
lastFrameTimeNs = frameTimeNanos;
checkNotifyUpdate(previousFrameRaw);
notifyRepeat();
repeatCount++;
}
} else {
checkNotifyUpdate(previousFrameRaw);
}

verifyFrame();
Expand All @@ -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;
Expand Down

0 comments on commit d9c853a

Please sign in to comment.