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

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: string update 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 private static final float NORMALIZED_INITIAL_SPEED = 1.5f;
David Trainor- moved to gerrit 2015/07/31 21:01:51 Can we add units to these? Are these in dp, perce
Kibeom Kim (inactive) 2015/07/31 21:42:50 This is a normalized scale, 0 to 1, and I wasn't s
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 float progressChange;
27 if (targetProgress == 1.0f) {
28 progressChange = FINISHING_SPEED * frameTimeSec;
29 } else {
30 progressChange = (targetProgress - mProgress)
31 * (1.0f - (float) Math.exp(-frameTimeSec * NORMALIZED_INITIA L_SPEED));
32 }
33
34 mProgress = Math.min(mProgress + progressChange, targetProgress);
35 if (targetProgress - mProgress < 0.5f / resolution) mProgress = targetPr ogress;
36
37 return mProgress;
38 }
39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698