OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.widget; | 5 package org.chromium.chrome.browser.widget; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.Canvas; | 8 import android.graphics.Canvas; |
9 import android.util.AttributeSet; | 9 import android.util.AttributeSet; |
10 import android.widget.ProgressBar; | 10 import android.widget.ProgressBar; |
11 | 11 |
12 import org.chromium.base.annotations.SuppressFBWarnings; | 12 import org.chromium.base.annotations.SuppressFBWarnings; |
13 | 13 |
14 /** | 14 /** |
15 * A throttled version of {@link ProgressBar}. This steals calls to | 15 * A throttled version of {@link ProgressBar}. This steals calls to |
16 * {@link android.view.View#postInvalidateOnAnimation} and delays them if necess
ary to reach a | 16 * {@link android.view.View#postInvalidateOnAnimation} and delays them if necess
ary to reach a |
17 * specific FPS. | 17 * specific FPS. |
18 */ | 18 */ |
19 public class SlowedProgressBar extends ProgressBar { | 19 public class SlowedProgressBar extends ProgressBar { |
20 private long mLastDrawTimeMs = 0; | 20 private long mLastDrawTimeMs; |
21 private boolean mPendingInvalidation = false; | 21 private boolean mPendingInvalidation; |
22 private static final int MIN_MS_PER_FRAME = 66; | 22 private static final int MIN_MS_PER_FRAME = 66; |
23 private int mTargetProgress; | 23 private int mTargetProgress; |
24 | 24 |
25 private final Runnable mInvalidationRunnable = new Runnable() { | 25 private final Runnable mInvalidationRunnable = new Runnable() { |
26 @Override | 26 @Override |
27 public void run() { | 27 public void run() { |
28 mPendingInvalidation = false; | 28 mPendingInvalidation = false; |
29 invalidate(); | 29 invalidate(); |
30 } | 30 } |
31 }; | 31 }; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 /** | 102 /** |
103 * Called to update the progress visuals. | 103 * Called to update the progress visuals. |
104 * @param progress The progress value to set the visuals to. | 104 * @param progress The progress value to set the visuals to. |
105 */ | 105 */ |
106 protected void setProgressInternal(int progress) { | 106 protected void setProgressInternal(int progress) { |
107 super.setProgress(progress); | 107 super.setProgress(progress); |
108 } | 108 } |
109 } | 109 } |
OLD | NEW |