summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chet Haase <chet@google.com> 2011-08-22 14:27:51 -0700
committer Chet Haase <chet@google.com> 2011-08-22 14:27:51 -0700
commita68c5cf8a111d0c901474b5819d49ca5eea42a65 (patch)
tree48894e2080cda6ca79ba829db845675bed053a32
parent5e82bc038385edcb669b44659401fb83dab9c880 (diff)
Fix invalidation bug with INVISIBLE views.
There was a bug in the invalidation code that prevented some animations fropm starting. An INVISIBLE view would mark some dirty flags then propagate the invaliation up the parent hierarchy. This would cause a redraw of the hierarchy, but would not include the invisible view (invisible children do not get drawn). Thus the flags wouldn't get cleared. Later, an animation to fade the view in (making it VISIBLE on start) would be started on the view. But the invalidation triggered by that animation would not propagate because the invisible view would see that it was already invalidated, and wouldn't send the message along. No invalidation means no drawing, so the animation wouldn't start because the invalidation didn't make it's way up to the top and the child's parent did not redraw. The fix is to noop the invalidate() call for GONE/INVISIBLE views which do not have animations set on them. Making these views VISIBLE later will trigger an invalidation, as will starting an animation on them, so the behavior should not change except for the buggy situation. Change-Id: I7a26a4bc7823f08fef56e52648e77ca256df6858
-rw-r--r--core/java/android/view/View.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index abd9ad6ce616..8006185014ca 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -8087,6 +8087,11 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
ViewDebug.trace(this, ViewDebug.HierarchyTraceType.INVALIDATE);
}
+ if ((mViewFlags & VISIBILITY_MASK) != VISIBLE && mCurrentAnimation == null) {
+ // Noop for views which are not visible and which are not running an animation. They
+ // will not get drawn and they should not set dirty flags as if they will be drawn
+ return;
+ }
if ((mPrivateFlags & (DRAWN | HAS_BOUNDS)) == (DRAWN | HAS_BOUNDS) ||
(mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID ||
(mPrivateFlags & INVALIDATED) != INVALIDATED) {
@@ -8130,6 +8135,11 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
ViewDebug.trace(this, ViewDebug.HierarchyTraceType.INVALIDATE);
}
+ if ((mViewFlags & VISIBILITY_MASK) != VISIBLE && mCurrentAnimation == null) {
+ // Noop for views which are not visible and which are not running an animation. They
+ // will not get drawn and they should not set dirty flags as if they will be drawn
+ return;
+ }
if ((mPrivateFlags & (DRAWN | HAS_BOUNDS)) == (DRAWN | HAS_BOUNDS) ||
(mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID ||
(mPrivateFlags & INVALIDATED) != INVALIDATED) {
@@ -8182,6 +8192,11 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
ViewDebug.trace(this, ViewDebug.HierarchyTraceType.INVALIDATE);
}
+ if ((mViewFlags & VISIBILITY_MASK) != VISIBLE && mCurrentAnimation == null) {
+ // Noop for views which are not visible and which are not running an animation. They
+ // will not get drawn and they should not set dirty flags as if they will be drawn
+ return;
+ }
if ((mPrivateFlags & (DRAWN | HAS_BOUNDS)) == (DRAWN | HAS_BOUNDS) ||
(invalidateCache && (mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID) ||
(mPrivateFlags & INVALIDATED) != INVALIDATED || isOpaque() != mLastIsOpaque) {
@@ -8217,6 +8232,11 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
* @hide
*/
public void fastInvalidate() {
+ if ((mViewFlags & VISIBILITY_MASK) != VISIBLE && mCurrentAnimation == null) {
+ // Noop for views which are not visible and which are not running an animation. They
+ // will not get drawn and they should not set dirty flags as if they will be drawn
+ return;
+ }
if ((mPrivateFlags & (DRAWN | HAS_BOUNDS)) == (DRAWN | HAS_BOUNDS) ||
(mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID ||
(mPrivateFlags & INVALIDATED) != INVALIDATED) {