mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
e6d498b99b
Reviewed By: astreet Differential Revision: D2760119 fb-gh-sync-id: cf2723ddc94de64bba961e9390ce54f39ca4651f
37 lines
951 B
Java
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;
|
|
}
|
|
}
|
|
}
|