public abstract class Component extends ComponentLifecycle implements 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(String simpleName) |
protected |
Component(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,
Object value,
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(Component component) |
CommonProps |
getCommonProps() |
protected DynamicValue[] |
getDynamicProps() |
EventDispatcher |
getEventDispatcher()
Deprecated.
|
protected Handle |
getHandle() |
protected int |
getId() |
protected String |
getKey() |
ComponentContext |
getScopedContext() |
String |
getSimpleName()
Should only be used by logging to provide more readable messages.
|
protected Component |
getSimpleNameDelegate() |
protected StateContainer |
getStateContainer() |
boolean |
hasBackgroundSet() |
boolean |
hasClickHandlerSet() |
boolean |
isEquivalentTo(Component other)
Compares this component to a different one to check if they are the same
|
Component |
makeShallowCopy() |
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(EventTriggersContainer container) |
protected static void |
registerWorkingRange(String name,
WorkingRange workingRange,
Component component)
Store a working range information into a list for later use by
LayoutState . |
protected static <T> T |
retrieveValue(DynamicValue<T> dynamicValue) |
void |
setScopedContext(ComponentContext scopedContext) |
protected void |
updateInternalChildState(ComponentContext parentContext)
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, applyPreviousRenderData, callsShouldUpdateOnMount, canMeasure, canPreallocate, createInitialState, createMountContent, dispatchErrorEvent, dispatchErrorEvent, dispatchOnEnteredRange, dispatchOnEvent, dispatchOnExitedRange, getEventTrigger, getEventTrigger, getExtraAccessibilityNodeAt, getExtraAccessibilityNodesCount, getMountType, getTreePropsForChildren, hasAttachDetachCallback, hasChildLithoViews, hasState, implementsAccessibility, implementsExtraAccessibilityNodes, isLayoutSpecWithSizeSpecCheck, isMountSizeDependent, isPureRender, needsPreviousRenderData, newEventHandler, 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, shouldUseGlobalPool, transferState
protected Component()
protected Component(String simpleName)
protected Component(String simpleName, int identityHashCode)
Component(String)
instead.public void clearCachedLayout(ComponentContext c)
public CommonProps getCommonProps()
@Deprecated public EventDispatcher getEventDispatcher()
getEventDispatcher
in interface HasEventDispatcher
public ComponentContext getScopedContext()
public void setScopedContext(ComponentContext scopedContext)
public String getSimpleName()
public boolean hasBackgroundSet()
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(EventTriggersContainer container)
recordEventTrigger
in interface HasEventTrigger
protected Handle getHandle()
protected String getKey()
protected boolean canResolve()
ComponentLifecycle.resolve(ComponentContext)
logic
instead of going through ComponentLifecycle.createComponentLayout(ComponentContext)
.protected void copyInterStageImpl(Component component)
protected DynamicValue[] getDynamicProps()
protected int getId()
protected Component getSimpleNameDelegate()
LayoutSpec#simpleNameDelegate()
protected StateContainer getStateContainer()
protected void updateInternalChildState(ComponentContext parentContext)
@Deprecated public static boolean willRender(ComponentContext c, Component component)
protected static void registerWorkingRange(String name, WorkingRange workingRange, Component component)
LayoutState
.protected static <T> T retrieveValue(DynamicValue<T> dynamicValue)