mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Extract getViewportOffset out RootView
Summary: This diff moves the method getViewportOffset out of ReactRootView. This is necessary to avoid Fabric to depend from paper. changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D26716901 fbshipit-source-id: cec67c24860a776fb361d7cda08d3142e1214c8c
This commit is contained in:
1 parent
21a434ceec
commit
05f687fa88
6 files changed
+24
-20
No files matched your search
@@ -7,8 +7,11 @@
|
||||
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import androidx.annotation.UiThread;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
|
||||
public class RootViewUtil {
|
||||
@@ -28,4 +31,19 @@ public class RootViewUtil {
|
||||
current = (View) next;
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
public static Point getViewportOffset(View v) {
|
||||
int[] locationInWindow = new int[2];
|
||||
v.getLocationInWindow(locationInWindow);
|
||||
|
||||
// we need to subtract visibleWindowCoords - to subtract possible window insets, split
|
||||
// screen or multi window
|
||||
Rect visibleWindowFrame = new Rect();
|
||||
v.getWindowVisibleDisplayFrame(visibleWindowFrame);
|
||||
locationInWindow[0] -= visibleWindowFrame.left;
|
||||
locationInWindow[1] -= visibleWindowFrame.top;
|
||||
|
||||
return new Point(locationInWindow[0], locationInWindow[1]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user