public int getExtraMemorySize() { if (getComponentTree() != null) { return getComponentTree().getExtraMemorySize(); } else { return ComponentsConfiguration.extraMemorySize; } } }
/** Whether the refactored implementation of nested tree resolution should be used. */ public boolean isNestedTreeResolutionExperimentEnabled() { if (getComponentTree() != null) { return getComponentTree().isNestedTreeResolutionExperimentEnabled(); } else { return false; } }
private static String generateGlobalKey(ComponentContext context, Component component) { final ComponentTree tree = context.getComponentTree(); final String componentKey = component.getGlobalKey(); return System.identityHashCode(tree) + componentKey; }
/** * Checks if incremental mount is enabled given a ComponentContext, so you can throw an error if * you require that incremental mount is enabled (e.g. you use visibility callbacks). This is * static to avoid polluting the ComponentContext API. */ public static boolean isIncrementalMountEnabled(ComponentContext c) { return c.getComponentTree().isIncrementalMountEnabled(); }
protected static <E> EventHandler<E> newEventHandler( ComponentContext c, int id, Object[] params) { final EventHandler<E> eventHandler = c.newEventHandler(id, params); if (c.getComponentTree() != null) { c.getComponentTree().recordEventHandler(c.getComponentScope(), eventHandler); } return eventHandler; }
/** * @return The litho view hosting this component. */ @Nullable public LithoView getLithoView() { final ComponentContext c = mNode.getContext(); final ComponentTree tree = c == null ? null : c.getComponentTree(); return tree == null ? null : tree.getLithoView(); }
/** * @return The root {@link DebugComponent} of a LithoView. This should be the start of your * traversal. */ @Nullable public static DebugComponent getRootInstance(Component component) { return getRootInstance(component.getScopedContext().getComponentTree()); }
/** Dumps the tree related to the provided component context */ @Nullable public static String dumpContextTree(@Nullable ComponentContext componentContext) { if (!ComponentsConfiguration.isDebugModeEnabled) { return "Dumping of the component" + " tree is not support on non-internal builds"; } if (componentContext == null) { return "ComponentContext is null"; } // Getting the base of the tree ComponentTree componentTree = componentContext.getComponentTree(); DebugComponent rootComponent = DebugComponent.getRootInstance(componentTree); if (rootComponent == null) { return null; } StringBuilder sb = new StringBuilder(); logComponent(rootComponent, 0, sb); return sb.toString(); }
protected static <E> EventHandler<E> newEventHandler( Component c, int id, Object[] params) { final EventHandler<E> eventHandler = new EventHandler<>(c, id, params); if (c.getScopedContext() != null && c.getScopedContext().getComponentTree() != null) { c.getScopedContext().getComponentTree().recordEventHandler(c, eventHandler); } return eventHandler; }
@Nullable protected static EventTrigger getEventTrigger(ComponentContext c, int id, String key) { if (c.getComponentScope() == null) { return null; } EventTrigger trigger = c.getComponentTree().getEventTrigger(c.getComponentScope().getGlobalKey() + id + key); if (trigger == null) { return null; } return trigger; }
/** * Show the given tooltip on the component with the given anchorKey with the specified offsets * from the given position. * * @deprecated * @see {{@link #showTooltip(ComponentContext, LithoTooltip, String, int, int)}} */ @Deprecated public static void showTooltip( ComponentContext c, DeprecatedLithoTooltip tooltip, String anchorKey, TooltipPosition tooltipPosition, int xOffset, int yOffset) { final ComponentTree componentTree = c.getComponentTree(); final Component rootComponent = c.getComponentScope(); if (componentTree == null) { return; } final String anchorGlobalKey = rootComponent == null ? anchorKey : ComponentKeyUtils.getKeyWithSeparator(rootComponent.getGlobalKey(), anchorKey); componentTree.showTooltip(tooltip, anchorGlobalKey, tooltipPosition, xOffset, yOffset); }
/** * 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); }
@Nullable private Object getMountedContent() { if (!isLayoutNode()) { return null; } final ComponentContext context = mNode.getContext(); final ComponentTree tree = context == null ? null : context.getComponentTree(); final LithoView view = tree == null ? null : tree.getLithoView(); final MountState mountState = view == null ? null : view.getMountState(); if (mountState != null) { for (int i = 0, count = mountState.getItemCount(); i < count; i++) { final MountItem mountItem = mountState.getItemAt(i); final Component component = mountItem == null ? null : mountItem.getComponent(); if (component != null && component == mNode.getRootComponent()) { return mountItem.getMountableContent(); } } } return null; } }
&& delegate.getScopedContext().getComponentTree() != null) { layoutState.mComponents.add(delegate);