OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.widget; |
| 6 |
| 7 /** |
| 8 * Progress bar animation logic that has linear speed. |
| 9 */ |
| 10 class ProgressAnimationLinear implements ToolbarProgressBar.AnimationLogic { |
| 11 // The speed unit is progress per second where 0 <= progress <= 1. |
| 12 private static final float NORMAL_SPEED = 0.5f; |
| 13 private static final float FINISHING_SPEED = 2.0f; |
| 14 |
| 15 private float mProgress; |
| 16 |
| 17 @Override |
| 18 public void reset() { |
| 19 mProgress = 0.0f; |
| 20 } |
| 21 |
| 22 @Override |
| 23 public float updateProgress(float targetProgress, float frameTimeSec, int re
solution) { |
| 24 assert mProgress <= targetProgress; |
| 25 |
| 26 mProgress = Math.min(targetProgress, mProgress |
| 27 + frameTimeSec * (targetProgress == 1.0f ? FINISHING_SPEED : NOR
MAL_SPEED)); |
| 28 return mProgress; |
| 29 } |
| 30 } |
OLD | NEW |