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

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

Issue 960733002: [Andorid] ClipDrawable progress bar experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated test Created 5 years, 10 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/widget/ToolbarProgressBar.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/widget/ClipDrawableProgressBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/ClipDrawableProgressBar.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/ClipDrawableProgressBar.java
new file mode 100644
index 0000000000000000000000000000000000000000..234183258f01ce845923bf2a9d74959cba422492
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/ClipDrawableProgressBar.java
@@ -0,0 +1,50 @@
+// 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;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+/**
+ * An alternative progress bar implemented using ClipDrawable. We're experimenting with this for
+ * faster performance. http://crbug.com/455891
+ */
+public class ClipDrawableProgressBar extends ImageView {
+ private static final long PROGRESS_CLEARING_DELAY_MS = 200;
+
+ private final Runnable mClearLoadProgressRunnable = new Runnable() {
+ @Override
+ public void run() {
+ setProgress(0);
+ }
+ };
+
+ /**
+ * Constructor for inflating from XML.
+ */
+ public ClipDrawableProgressBar(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ /**
+ * Set the current progress to the specified value.
+ * @param progress The new progress, between 0 and 10000.
+ */
+ public void setProgress(int progress) {
+ getDrawable().setLevel(progress);
+
+ removeCallbacks(mClearLoadProgressRunnable);
+ if (progress == 10000) postDelayed(mClearLoadProgressRunnable, PROGRESS_CLEARING_DELAY_MS);
+ }
+
+ /**
+ * Get the progress bar's current level of progress.
+ * @return The current progress, between 0 and getMax().
+ */
+ public int getProgress() {
+ return getDrawable().getLevel();
+ }
+}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/widget/ToolbarProgressBar.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698