From a05e8a5869ad2117485938cd52d4b891672a1873 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Thu, 25 Feb 2010 14:32:39 -0800 Subject: Prevent ProgressBar from updating itself when hidden. Bug #2470737 --- core/java/android/widget/ProgressBar.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'core/java') 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 @@ public class ProgressBar extends View { *

Start the indeterminate progress animation.

*/ void startAnimation() { - int visibility = getVisibility(); - if (visibility != VISIBLE) { + if (getVisibility() != VISIBLE) { return; } @@ -771,7 +770,7 @@ public class ProgressBar extends View { // let's be nice with the UI thread if (v == GONE || v == INVISIBLE) { stopAnimation(); - } else if (v == VISIBLE) { + } else { startAnimation(); } } @@ -779,6 +778,20 @@ public class ProgressBar extends View { } @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)) { -- cgit v1.1