summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adam Powell <adamp@google.com> 2011-12-12 15:40:00 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2011-12-12 15:40:00 -0800
commit9c92fcd91c67a98f3a767255e7d3748bca3ef751 (patch)
treeb950d11fd369e3ad77e0bc4e36507ead7e492a2f
parenta1dee3f500eccedbf5e50d466315fb28ba812cfc (diff)
parentf93bb6d8fd81d8938b16cf40259f97c336e9ef3a (diff)
Merge "Bug 5727679 - CTS test ViewGroupTest#testGetChildVisibleRect" into ics-mr1
-rw-r--r--core/java/android/view/ViewGroup.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 600bfe6c7e3a..ee66c4d15f8d 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);