diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-11-05 17:05:50 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2012-11-05 17:05:50 -0800 |
| commit | bb8abae507119612b4168b951354516b0bf7112d (patch) | |
| tree | fa56ff32d6ef604d31572ad3ca4d2a7f0f637f7b /core/java/android/view | |
| parent | 624ea44120dcf8e7305bbb54072417f189855187 (diff) | |
| parent | 0f4d5df5d815466398dba5f2d07aa98f18c35aaa (diff) | |
| download | frameworks_base-bb8abae507119612b4168b951354516b0bf7112d.zip frameworks_base-bb8abae507119612b4168b951354516b0bf7112d.tar.gz frameworks_base-bb8abae507119612b4168b951354516b0bf7112d.tar.bz2 | |
am 0f4d5df5: Merge "View\'s visibility to the user not checking predecessor alpha." into jb-mr1-dev
* commit '0f4d5df5d815466398dba5f2d07aa98f18c35aaa':
View's visibility to the user not checking predecessor alpha.
Diffstat (limited to 'core/java/android/view')
| -rw-r--r-- | core/java/android/view/View.java | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index d5e1ed3..ff44475 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5088,24 +5088,35 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ protected boolean isVisibleToUser(Rect boundInView) { if (mAttachInfo != null) { + // Attached to invisible window means this view is not visible. + if (mAttachInfo.mWindowVisibility != View.VISIBLE) { + return false; + } + // An invisible predecessor or one with alpha zero means + // that this view is not visible to the user. + Object current = this; + while (current instanceof View) { + View view = (View) current; + // We have attach info so this view is attached and there is no + // need to check whether we reach to ViewRootImpl on the way up. + if (view.getAlpha() <= 0 || view.getVisibility() != VISIBLE) { + return false; + } + current = view.mParent; + } + // Check if the view is entirely covered by its predecessors. Rect visibleRect = mAttachInfo.mTmpInvalRect; Point offset = mAttachInfo.mPoint; - // The first two checks are made also made by isShown() which - // however traverses the tree up to the parent to catch that. - // Therefore, we do some fail fast check to minimize the up - // tree traversal. - boolean isVisible = mAttachInfo.mWindowVisibility == View.VISIBLE - && getAlpha() > 0 - && isShown() - && getGlobalVisibleRect(visibleRect, offset); - if (isVisible && boundInView != null) { + if (!getGlobalVisibleRect(visibleRect, offset)) { + return false; + } + // Check if the visible portion intersects the rectangle of interest. + if (boundInView != null) { visibleRect.offset(-offset.x, -offset.y); - // isVisible is always true here, use a simple assignment - isVisible = boundInView.intersect(visibleRect); + return boundInView.intersect(visibleRect); } - return isVisible; + return true; } - return false; } |
