public abstract class Component extends ComponentLifecycle implements java.lang.Cloneable, HasEventDispatcher, HasEventTrigger, Equivalence<Component>
Modifier and Type | Class and Description |
---|---|
static class |
Component.Builder<T extends Component.Builder<T>> |
static class |
Component.ContainerBuilder<T extends Component.ContainerBuilder<T>> |
ComponentLifecycle.MountType, ComponentLifecycle.RenderData, ComponentLifecycle.TransitionContainer
Modifier | Constructor and Description |
---|---|
protected |
Component() |
protected |
Component(java.lang.String simpleName) |
protected |
Component(java.lang.String simpleName,
int identityHashCode)
This constructor should be called only if working with a manually crafted "special" Component.
|
Modifier and Type | Method and Description |
---|---|
protected void |
bindDynamicProp(int dynamicPropIndex,
java.lang.Object value,
java.lang.Object content) |
protected boolean |
canResolve()
Indicate that this component implements its own
ComponentLifecycle.resolve(ComponentContext) logic
instead of going through ComponentLifecycle.createComponentLayout(ComponentContext) . |
void |
clearCachedLayout(ComponentContext c)
Only use if absolutely needed! This removes the cached layout so this component will be
remeasured even if it has alread been measured with the same size specs.
|
protected void |
copyInterStageImpl(InterStagePropsContainer copyIntoInterStagePropsContainer,
InterStagePropsContainer copyFromInterStagePropsContainer) |
protected InterStagePropsContainer |
createInterStagePropsContainer() |
protected StateContainer |
createStateContainer() |
CommonProps |
getCommonProps() |
protected DynamicValue[] |
getDynamicProps() |
protected EventHandler<ErrorEvent> |
getErrorHandler() |
EventDispatcher |
getEventDispatcher()
Deprecated.
|
protected InterStagePropsContainer |
getInterStagePropsContainer(ComponentContext scopedContext) |
protected ComponentContext |
getScopedContext(LayoutStateContext layoutStateContext,
java.lang.String globalKey) |
java.lang.String |
getSimpleName()
Should only be used by logging to provide more readable messages.
|
protected Component |
getSimpleNameDelegate() |
protected static StateContainer |
getStateContainer(ComponentContext scopedContext,
Component component) |
boolean |
hasClickHandlerSet() |
boolean |
isEquivalentTo(Component other)
Compares this component to a different one to check if they are the same
|
Component |
makeShallowCopy() |
protected void |
markLayoutStarted() |
void |
measure(ComponentContext c,
int widthSpec,
int heightSpec,
Size outputSize)
Measure a component with the given
SizeSpec constrain. |
void |
measureMightNotCacheInternalNode(ComponentContext c,
int widthSpec,
int heightSpec,
Size outputSize)
Deprecated.
|
void |
recordEventTrigger(ComponentContext c,
EventTriggersContainer container) |
protected static void |
registerWorkingRange(ComponentContext scopedContext,
java.lang.String name,
WorkingRange workingRange,
Component component,
java.lang.String globalKey)
Store a working range information into a list for later use by
LayoutState . |
protected static <T> T |
retrieveValue(DynamicValue<T> dynamicValue) |
protected void |
setInterStagePropsContainer(InterStagePropsContainer interStagePropsContainer) |
void |
setScopedContext(ComponentContext scopedContext) |
protected void |
setStateContainer(StateContainer stateContainer) |
java.lang.String |
toString() |
protected ComponentContext |
updateInternalChildState(ComponentContext parentContext,
java.lang.String existingGlobalKey)
Called to install internal state based on a component's parent context.
|
static boolean |
willRender(ComponentContext c,
Component component)
Deprecated.
Using willRender is regarded as an anti-pattern, since it will load all classes
into memory in order to potentially decide not to use any of them.
|
acceptTriggerEvent, acceptTriggerEventImpl, applyPreviousRenderData, callsShouldUpdateOnMount, canMeasure, canPreallocate, createInitialState, createMountContent, dispatchErrorEvent, dispatchErrorEvent, dispatchOnEnteredRange, dispatchOnEvent, dispatchOnEventImpl, dispatchOnExitedRange, getEventTrigger, getEventTrigger, getExtraAccessibilityNodeAt, getExtraAccessibilityNodesCount, getMountType, getTreePropsForChildren, hasAttachDetachCallback, hasChildLithoViews, hasOwnErrorHandler, hasState, implementsAccessibility, implementsExtraAccessibilityNodes, isLayoutSpecWithSizeSpecCheck, isMountSizeDependent, isPureRender, needsPreviousRenderData, newEventHandler, newEventTrigger, newEventTrigger, onAttached, onBind, onBoundsDefined, onCreateLayout, onCreateLayoutWithSizeSpec, onCreateMountContent, onCreateMountContentPool, onCreateTransition, onDetached, onError, onLoadStyle, onMeasure, onMeasureBaseline, onMount, onPopulateAccessibilityNode, onPopulateExtraAccessibilityNode, onPrepare, onShouldCreateLayoutWithNewSizeSpec, onUnbind, onUnmount, poolSize, populateTreeProps, recordRenderData, resolve, shouldAlwaysRemeasure, shouldUpdate, transferState
protected Component()
protected Component(java.lang.String simpleName)
protected Component(java.lang.String simpleName, int identityHashCode)
Component(String)
instead.public void clearCachedLayout(ComponentContext c)
public CommonProps getCommonProps()
@Deprecated public EventDispatcher getEventDispatcher()
getEventDispatcher
in interface HasEventDispatcher
protected ComponentContext getScopedContext(LayoutStateContext layoutStateContext, java.lang.String globalKey)
public void setScopedContext(ComponentContext scopedContext)
public java.lang.String getSimpleName()
public boolean hasClickHandlerSet()
public boolean isEquivalentTo(Component other)
This is used to be able to skip rendering a component again. We avoid using the Object.equals(Object)
so we can optimize the code better over time since we don't have to
adhere to the contract required for a equals method.
isEquivalentTo
in interface Equivalence<Component>
other
- the component to compare topublic Component makeShallowCopy()
public void measure(ComponentContext c, int widthSpec, int heightSpec, Size outputSize)
SizeSpec
constrain.c
- ComponentContext
.widthSpec
- Width SizeSpec
constrain.heightSpec
- Height SizeSpec
constrain.outputSize
- Size object that will be set with the measured dimensions.@Deprecated public void measureMightNotCacheInternalNode(ComponentContext c, int widthSpec, int heightSpec, Size outputSize)
This is very inefficient because it throws away the InternalNode from measuring here and will have to remeasure when the component needs to be measured as part of a LayoutState. This will lead to suboptimal performance.
You probably don't need to use this. If you really need to measure your Component outside of a LayoutState calculation reach out to the Litho team to discuss an alternative solution.
If this is called during a LayoutState calculation, it will delegate to ComponentLifecycle.onMeasure(ComponentContext, ComponentLayout, int, int, Size)
, which does cache the
measurement result for the duration of this LayoutState.
public void recordEventTrigger(ComponentContext c, EventTriggersContainer container)
recordEventTrigger
in interface HasEventTrigger
protected EventHandler<ErrorEvent> getErrorHandler()
protected void markLayoutStarted()
protected void bindDynamicProp(int dynamicPropIndex, java.lang.Object value, java.lang.Object content)
protected boolean canResolve()
ComponentLifecycle.resolve(ComponentContext)
logic
instead of going through ComponentLifecycle.createComponentLayout(ComponentContext)
.protected void copyInterStageImpl(InterStagePropsContainer copyIntoInterStagePropsContainer, InterStagePropsContainer copyFromInterStagePropsContainer)
protected DynamicValue[] getDynamicProps()
protected Component getSimpleNameDelegate()
LayoutSpec#simpleNameDelegate()
protected static StateContainer getStateContainer(ComponentContext scopedContext, Component component)
protected void setStateContainer(StateContainer stateContainer)
protected void setInterStagePropsContainer(InterStagePropsContainer interStagePropsContainer)
protected StateContainer createStateContainer()
public java.lang.String toString()
toString
in class java.lang.Object
protected InterStagePropsContainer getInterStagePropsContainer(ComponentContext scopedContext)
protected InterStagePropsContainer createInterStagePropsContainer()
protected ComponentContext updateInternalChildState(ComponentContext parentContext, java.lang.String existingGlobalKey)
@Deprecated public static boolean willRender(ComponentContext c, Component component)
protected static void registerWorkingRange(ComponentContext scopedContext, java.lang.String name, WorkingRange workingRange, Component component, java.lang.String globalKey)
LayoutState
.protected static <T> T retrieveValue(DynamicValue<T> dynamicValue)