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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationLinear.java

Issue 1279873003: [Android] Add progress bar linear animation option. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationLinear.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationLinear.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationLinear.java
new file mode 100644
index 0000000000000000000000000000000000000000..c5f6925573c0644e6a784b75f40afdc42e86680e
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/ProgressAnimationLinear.java
@@ -0,0 +1,30 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.widget;
+
+/**
+ * Progress bar animation logic that has linear speed.
+ */
+class ProgressAnimationLinear implements ToolbarProgressBar.AnimationLogic {
+ // The speed unit is progress per second where 0 <= progress <= 1.
+ private static final float NORMAL_SPEED = 0.5f;
+ private static final float FINISHING_SPEED = 2.0f;
+
+ private float mProgress;
+
+ @Override
+ public void reset() {
+ mProgress = 0.0f;
+ }
+
+ @Override
+ public float updateProgress(float targetProgress, float frameTimeSec, int resolution) {
+ assert mProgress <= targetProgress;
+
+ mProgress = Math.min(targetProgress, mProgress
+ + frameTimeSec * (targetProgress == 1.0f ? FINISHING_SPEED : NORMAL_SPEED));
+ return mProgress;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698