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.
This commit is contained in:
@@ -5088,24 +5088,35 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
*/
|
*/
|
||||||
protected boolean isVisibleToUser(Rect boundInView) {
|
protected boolean isVisibleToUser(Rect boundInView) {
|
||||||
if (mAttachInfo != null) {
|
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;
|
Rect visibleRect = mAttachInfo.mTmpInvalRect;
|
||||||
Point offset = mAttachInfo.mPoint;
|
Point offset = mAttachInfo.mPoint;
|
||||||
// The first two checks are made also made by isShown() which
|
if (!getGlobalVisibleRect(visibleRect, offset)) {
|
||||||
// however traverses the tree up to the parent to catch that.
|
return false;
|
||||||
// Therefore, we do some fail fast check to minimize the up
|
}
|
||||||
// tree traversal.
|
// Check if the visible portion intersects the rectangle of interest.
|
||||||
boolean isVisible = mAttachInfo.mWindowVisibility == View.VISIBLE
|
if (boundInView != null) {
|
||||||
&& getAlpha() > 0
|
|
||||||
&& isShown()
|
|
||||||
&& getGlobalVisibleRect(visibleRect, offset);
|
|
||||||
if (isVisible && boundInView != null) {
|
|
||||||
visibleRect.offset(-offset.x, -offset.y);
|
visibleRect.offset(-offset.x, -offset.y);
|
||||||
// isVisible is always true here, use a simple assignment
|
return boundInView.intersect(visibleRect);
|
||||||
isVisible = boundInView.intersect(visibleRect);
|
|
||||||
}
|
}
|
||||||
return isVisible;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user