| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.widget; | 5 package org.chromium.chrome.browser.widget; |
| 6 | 6 |
| 7 import android.animation.TimeAnimator; | 7 import android.animation.TimeAnimator; |
| 8 import android.animation.TimeAnimator.TimeListener; | 8 import android.animation.TimeAnimator.TimeListener; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.graphics.Color; | 10 import android.graphics.Color; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 private final TimeAnimator mProgressAnimator = new TimeAnimator(); | 91 private final TimeAnimator mProgressAnimator = new TimeAnimator(); |
| 92 { | 92 { |
| 93 mProgressAnimator.setTimeListener(new TimeListener() { | 93 mProgressAnimator.setTimeListener(new TimeListener() { |
| 94 @Override | 94 @Override |
| 95 public void onTimeUpdate(TimeAnimator animation, long totalTimeMs, l
ong deltaTimeMs) { | 95 public void onTimeUpdate(TimeAnimator animation, long totalTimeMs, l
ong deltaTimeMs) { |
| 96 // Cap progress bar animation frame time so that it doesn't jump
too much even when | 96 // Cap progress bar animation frame time so that it doesn't jump
too much even when |
| 97 // the animation is janky. | 97 // the animation is janky. |
| 98 float progress = mAnimationLogic.updateProgress(mTargetProgress, | 98 float progress = mAnimationLogic.updateProgress(mTargetProgress, |
| 99 Math.max(deltaTimeMs, PROGRESS_FRAME_TIME_CAP_MS) * 0.00
1f, getWidth()); | 99 Math.min(deltaTimeMs, PROGRESS_FRAME_TIME_CAP_MS) * 0.00
1f, getWidth()); |
| 100 ToolbarProgressBar.super.setProgress(progress); | 100 ToolbarProgressBar.super.setProgress(progress); |
| 101 | 101 |
| 102 if (mAnimatingView != null) { | 102 if (mAnimatingView != null) { |
| 103 int width = getDrawable().getBounds().right - getDrawable().
getBounds().left; | 103 int width = getDrawable().getBounds().right - getDrawable().
getBounds().left; |
| 104 mAnimatingView.update(progress * width); | 104 mAnimatingView.update(progress * width); |
| 105 | 105 |
| 106 // If the progress bar was updated, reset the callback that
triggers the | 106 // If the progress bar was updated, reset the callback that
triggers the |
| 107 // indeterminate animation. | 107 // indeterminate animation. |
| 108 removeCallbacks(mStartIndeterminate); | 108 removeCallbacks(mStartIndeterminate); |
| 109 if (progress == 1.0) { | 109 if (progress == 1.0) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 342 |
| 343 @Override | 343 @Override |
| 344 public void setForegroundColor(int color) { | 344 public void setForegroundColor(int color) { |
| 345 super.setForegroundColor(color); | 345 super.setForegroundColor(color); |
| 346 if (mAnimatingView != null) { | 346 if (mAnimatingView != null) { |
| 347 mAnimatingView.setColor(ColorUtils.getColorWithOverlay(color, Color.
WHITE, | 347 mAnimatingView.setColor(ColorUtils.getColorWithOverlay(color, Color.
WHITE, |
| 348 ANIMATION_WHITE_FRACTION)); | 348 ANIMATION_WHITE_FRACTION)); |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 } | 351 } |
| OLD | NEW |