Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationFastStart.java

Issue 1256343004: [Android] Add phone progress bar animation behind a flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: telemetry_perf_unittest fix attempt #1 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 starts fast at the beginning and slows down approaching to the
9 * end.
10 */
11 class ProgressAnimationFastStart implements ToolbarProgressBar.AnimationLogic {
12 // The speed unit is progress per second where 0 <= progress <= 1.
13 private static final float NORMALIZED_INITIAL_SPEED = 1.5f;
14 private static final float FINISHING_SPEED = 2.0f;
15
16 private float mProgress;
17
18 @Override
19 public void reset() {
20 mProgress = 0.0f;
21 }
22
23 @Override
24 public float updateProgress(float targetProgress, float frameTimeSec, int re solution) {
25 assert mProgress <= targetProgress;
26
27 float progressChange;
28 if (targetProgress == 1.0f) {
29 progressChange = FINISHING_SPEED * frameTimeSec;
30 } else {
31 progressChange = (targetProgress - mProgress)
32 * (1.0f - (float) Math.exp(-frameTimeSec * NORMALIZED_INITIA L_SPEED));
33 }
34
35 mProgress = Math.min(mProgress + progressChange, targetProgress);
36 if (targetProgress - mProgress < 0.5f / resolution) mProgress = targetPr ogress;
37
38 return mProgress;
39 }
40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698