Fix case where measure is called with a view that is now off screen (and removed from clipping)

Reviewed By: astreet

Differential Revision: D2760119

fb-gh-sync-id: cf2723ddc94de64bba961e9390ce54f39ca4651f
This commit is contained in:
Dave Miller
2015-12-15 10:42:08 -08:00
committed by facebook-github-bot-5
parent 5ebef01e9b
commit e6d498b99b
2 changed files with 8 additions and 1 deletions

View File

@@ -467,6 +467,11 @@ public class NativeViewHierarchyManager {
}
View rootView = (View) RootViewUtil.getRootView(v);
// It is possible that the RootView can't be found because this view is no longer on the screen
// and has been removed by clipping
if (rootView == null) {
throw new NoSuchNativeViewException("Native view " + tag + " is no longer on screen");
}
rootView.getLocationInWindow(outputBuffer);
int rootX = outputBuffer[0];
int rootY = outputBuffer[1];

View File

@@ -26,7 +26,9 @@ public class RootViewUtil {
return (RootView) current;
}
ViewParent next = current.getParent();
Assertions.assertNotNull(next);
if (next == null) {
return null;
}
Assertions.assertCondition(next instanceof View);
current = (View) next;
}