From aed1687a45749b73386e0e79d0452396960893d9 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Sun, 16 Aug 2020 22:44:27 +0300 Subject: [PATCH] Improved an animation logic --- .../newpipe/fragments/detail/VideoDetailFragment.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index d014c5b38..29b943f7f 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1769,10 +1769,11 @@ public class VideoDetailFragment private void showPlaybackProgress(final long progress, final long duration) { final int progressSeconds = (int) TimeUnit.MILLISECONDS.toSeconds(progress); final int durationSeconds = (int) TimeUnit.MILLISECONDS.toSeconds(duration); + // If the old and the new progress values have a big difference then use + // animation. Otherwise don't because it affects CPU + final boolean shouldAnimate = Math.abs(positionView.getProgress() - progressSeconds) > 2; positionView.setMax(durationSeconds); - // If there is no player inside fragment use animation, otherwise don't because - // it affects CPU - if (playerPlaceholder.getChildCount() == 0) { + if (shouldAnimate) { positionView.setProgressAnimated(progressSeconds); } else { positionView.setProgress(progressSeconds);