Commit 0234f4bd authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

Prevent progress bar from freezing

In cases where the indeterminate animation was running and stopped,
if progress jumped to 100%, the progress bar would remain on-screen.
In most cases, if the progress bar reaches 100%, the progress bar is
hidden immediately. If the animation is running, the user should be
able to see progress reach 100% before it disappears. The discrepancy
was in this logic. This change ensures that the progress bar restarts
animation on update and blocks finish until the animation is complete.

BUG=780856

Change-Id: Ife33e5d69824cb48b03a38312f817a31963b848a
Reviewed-on: https://chromium-review.googlesource.com/766848Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516052}
parent 4efbba62
......@@ -161,9 +161,10 @@ public class ToolbarProgressBar extends ClipDrawableProgressBar {
mAnimatingView.update(progress * width);
}
if (getProgress() == mTargetProgress) {
if (MathUtils.areFloatsEqual(getProgress(), mTargetProgress)) {
if (!mIsStarted) postOnAnimationDelayed(mHideRunnable, mHidingDelayMs);
mProgressAnimator.end();
if (MathUtils.areFloatsEqual(getProgress(), 1.f)) finish(false);
return;
}
}
......@@ -349,7 +350,10 @@ public class ToolbarProgressBar extends ClipDrawableProgressBar {
* @param delayed Whether a delayed fading out animation should be posted.
*/
public void finish(boolean delayed) {
if (mProgressThrottle != null && mProgressThrottle.isRunning()) return;
if (mProgressThrottle != null && mProgressThrottle.isRunning()
|| mAnimatingView != null && mAnimatingView.isRunning()) {
return;
}
mIsStarted = false;
......@@ -423,10 +427,10 @@ public class ToolbarProgressBar extends ClipDrawableProgressBar {
}
private void updateVisibleProgress() {
if (mStartSmoothAnimation) {
if (mStartSmoothAnimation || (mAnimatingView != null && mAnimatingView.isRunning())) {
// The progress animator will stop if the animation reaches the target progress. If the
// animation was running for the current page load, keep running it.
if (!mProgressAnimator.isRunning()) mProgressAnimator.start();
mProgressAnimator.start();
} else {
super.setProgress(mTargetProgress);
if (!mIsStarted) postOnAnimationDelayed(mHideRunnable, mHidingDelayMs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment