diff options
author | Adam Powell <adamp@google.com> | 2011-12-12 15:21:57 -0800 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2011-12-12 15:23:12 -0800 |
commit | f93bb6d8fd81d8938b16cf40259f97c336e9ef3a (patch) | |
tree | db4caccc67857ea07d9f89e0d0695c88a9953c15 | |
parent | 2ace3b01ab9447ce9fda2f578e31c1c11f4837cb (diff) | |
download | frameworks_base-f93bb6d8fd81d8938b16cf40259f97c336e9ef3a.zip frameworks_base-f93bb6d8fd81d8938b16cf40259f97c336e9ef3a.tar.gz frameworks_base-f93bb6d8fd81d8938b16cf40259f97c336e9ef3a.tar.bz2 |
Bug 5727679 - CTS test ViewGroupTest#testGetChildVisibleRect
Preserve the ability to call getChildVisibleRect without the view
being attached to a window.
Change-Id: I702b19fa1625c346eb22fda4a4ffb6e8f790b689
-rw-r--r-- | core/java/android/view/ViewGroup.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 600bfe6..ee66c4d 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -4176,10 +4176,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * {@inheritDoc} */ public boolean getChildVisibleRect(View child, Rect r, android.graphics.Point offset) { - // The View is not attached to a window, 'visible' does not make sense, return false - if (mAttachInfo == null) return false; - - final RectF rect = mAttachInfo.mTmpTransformRect; + // It doesn't make a whole lot of sense to call this on a view that isn't attached, + // but for some simple tests it can be useful. If we don't have attach info this + // will allocate memory. + final RectF rect = mAttachInfo != null ? mAttachInfo.mTmpTransformRect : new RectF(); rect.set(r); if (!child.hasIdentityMatrix()) { @@ -4193,7 +4193,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (offset != null) { if (!child.hasIdentityMatrix()) { - float[] position = mAttachInfo.mTmpTransformLocation; + float[] position = mAttachInfo != null ? mAttachInfo.mTmpTransformLocation + : new float[2]; position[0] = offset.x; position[1] = offset.y; child.getMatrix().mapPoints(position); |