/** * Returns true if the component is in the focused visible range. */ private boolean isInFocusedRange( Rect componentBounds, Rect componentVisibleBounds) { final View parent = (View) mLithoView.getParent(); if (parent == null) { return false; } final int halfViewportArea = parent.getWidth() * parent.getHeight() / 2; final int totalComponentArea = computeRectArea(componentBounds); final int visibleComponentArea = computeRectArea(componentVisibleBounds); // The component has entered the focused range either if it is larger than half of the viewport // and it occupies at least half of the viewport or if it is smaller than half of the viewport // and it is fully visible. return (totalComponentArea >= halfViewportArea) ? (visibleComponentArea >= halfViewportArea) : componentBounds.equals(componentVisibleBounds); }
ViewParent viewParent = lithoView.getParent(); while (viewParent != null) { if (viewParent instanceof ViewPager) {
/** * Provide a nested string representation of a LithoView and its nested components for debugging * purposes. * * @param view A Litho view with mounted components. * @param embedded if the call is embedded in "adb dumpsys activity" */ @DoNotStrip public static String viewToString(LithoView view, boolean embedded) { int left = 0; int top = 0; int depth = 0; if (embedded) { left = view.getLeft(); top = view.getTop(); depth = 2; ViewParent parent = view.getParent(); while (parent != null) { depth++; parent = parent.getParent(); } } final StringBuilder sb = new StringBuilder(); viewToString(left, top, DebugComponent.getRootInstance(view), sb, embedded, depth); return sb.toString(); }
when(mLithoView.getParent()).thenReturn(viewPager);
int widthSpec, int heightSpec) { final boolean addParent = lithoView.getParent() == null; final ViewGroup parent = new ViewGroup(lithoView.getContext()) {