Files
react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.java
T
Dave Miller e6d498b99b 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
2015-12-15 10:43:29 -08:00

37 lines
951 B
Java

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.react.uimanager;
import android.view.View;
import android.view.ViewParent;
import com.facebook.infer.annotation.Assertions;
public class RootViewUtil {
/**
* Returns the root view of a given view in a react application.
*/
public static RootView getRootView(View reactView) {
View current = reactView;
while (true) {
if (current instanceof RootView) {
return (RootView) current;
}
ViewParent next = current.getParent();
if (next == null) {
return null;
}
Assertions.assertCondition(next instanceof View);
current = (View) next;
}
}
}