Skip to content

Commit 9c92fcd

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Bug 5727679 - CTS test ViewGroupTest#testGetChildVisibleRect" into ics-mr1
2 parents a1dee3f + f93bb6d commit 9c92fcd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/java/android/view/ViewGroup.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,10 +4176,10 @@ public void offsetChildrenTopAndBottom(int offset) {
41764176
* {@inheritDoc}
41774177
*/
41784178
public boolean getChildVisibleRect(View child, Rect r, android.graphics.Point offset) {
4179-
// The View is not attached to a window, 'visible' does not make sense, return false
4180-
if (mAttachInfo == null) return false;
4181-
4182-
final RectF rect = mAttachInfo.mTmpTransformRect;
4179+
// It doesn't make a whole lot of sense to call this on a view that isn't attached,
4180+
// but for some simple tests it can be useful. If we don't have attach info this
4181+
// will allocate memory.
4182+
final RectF rect = mAttachInfo != null ? mAttachInfo.mTmpTransformRect : new RectF();
41834183
rect.set(r);
41844184

41854185
if (!child.hasIdentityMatrix()) {
@@ -4193,7 +4193,8 @@ public boolean getChildVisibleRect(View child, Rect r, android.graphics.Point of
41934193

41944194
if (offset != null) {
41954195
if (!child.hasIdentityMatrix()) {
4196-
float[] position = mAttachInfo.mTmpTransformLocation;
4196+
float[] position = mAttachInfo != null ? mAttachInfo.mTmpTransformLocation
4197+
: new float[2];
41974198
position[0] = offset.x;
41984199
position[1] = offset.y;
41994200
child.getMatrix().mapPoints(position);

0 commit comments

Comments
 (0)