Prevent ProgressBar from updating itself when hidden.
Bug #2470737
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index 6dc9f78..202e658 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -696,8 +696,7 @@
* <p>Start the indeterminate progress animation.</p>
*/
void startAnimation() {
- int visibility = getVisibility();
- if (visibility != VISIBLE) {
+ if (getVisibility() != VISIBLE) {
return;
}
@@ -771,7 +770,7 @@
// let's be nice with the UI thread
if (v == GONE || v == INVISIBLE) {
stopAnimation();
- } else if (v == VISIBLE) {
+ } else {
startAnimation();
}
}
@@ -779,6 +778,20 @@
}
@Override
+ protected void onVisibilityChanged(View changedView, int visibility) {
+ super.onVisibilityChanged(changedView, visibility);
+
+ if (mIndeterminate) {
+ // let's be nice with the UI thread
+ if (visibility == GONE || visibility == INVISIBLE) {
+ stopAnimation();
+ } else {
+ startAnimation();
+ }
+ }
+ }
+
+ @Override
public void invalidateDrawable(Drawable dr) {
if (!mInDrawing) {
if (verifyDrawable(dr)) {