@GuardedBy("this") private void acquireAnimationState() { if (mComponentTree == null) { return; } mHasMounted = mComponentTree.hasMounted(); } }
/** * Show the given tooltip on the component with the given anchorKey. * * @param c * @param lithoTooltip A {@link LithoTooltip} implementation to be shown on the anchor. * @param anchorKey key of the Litho Component that will be used as anchor * @param xOffset horizontal offset from default position where the tooltip shows. * @param yOffset vertical offset from default position where the tooltip shows. */ public static void showTooltip( ComponentContext c, LithoTooltip lithoTooltip, String anchorKey, int xOffset, int yOffset) { final ComponentTree componentTree = c.getComponentTree(); final Component rootComponent = c.getComponentScope(); if (componentTree == null || componentTree.isReleased() || !componentTree.hasMounted()) { return; } final String anchorGlobalKey = rootComponent == null ? anchorKey : ComponentKeyUtils.getKeyWithSeparator(rootComponent.getGlobalKey(), anchorKey); componentTree.showTooltip(lithoTooltip, anchorGlobalKey, xOffset, yOffset); }
@Test public void testRetainAnimationStateAfterExitingRange() { ComponentTreeHolder holder = createComponentTreeHolder(mComponentRenderInfo); holder.computeLayoutSync(mContext, mWidthSpec, mHeightSpec, new Size()); assertThat(holder.getComponentTree().hasMounted()).isFalse(); Whitebox.setInternalState(holder.getComponentTree(), "mHasMounted", true); // component goes out of range holder.acquireStateAndReleaseTree(); assertThat(holder.getComponentTree()).isNull(); // component comes back within range holder.computeLayoutSync(mContext, mWidthSpec, mHeightSpec, new Size()); assertThat(holder.getComponentTree().hasMounted()).isTrue(); }
!mSuppressMeasureComponentTree && mComponentTree != null && (!mHasNewComponentTree || !mComponentTree.hasMounted());