public class ComponentContext
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static InternalNode |
NULL_LAYOUT |
Constructor and Description |
---|
ComponentContext(ComponentContext context,
StateHandler stateHandler,
TreeProps treeProps,
LayoutStateContext layoutStateContext) |
ComponentContext(Context context) |
ComponentContext(Context context,
java.lang.String logTag,
ComponentsLogger logger)
Constructor that can be used to receive log data from components.
|
ComponentContext(Context context,
java.lang.String logTag,
ComponentsLogger logger,
TreeProps treeProps) |
Modifier and Type | Method and Description |
---|---|
void |
applyLazyStateUpdatesForContainer(StateContainer container) |
Context |
getAndroidContext() |
Context |
getApplicationContext() |
java.lang.Object |
getCachedValue(java.lang.Object cachedValueInputs) |
int |
getColor(int id) |
Component |
getComponentScope() |
EventHandler<ErrorEvent> |
getErrorEventHandler() |
java.lang.String |
getGlobalKey() |
LayoutStateContext |
getLayoutStateContext() |
com.facebook.litho.ComponentTree.LayoutStateFuture |
getLayoutStateFuture() |
int |
getLayoutVersion() |
ComponentsLogger |
getLogger() |
java.lang.String |
getLogTag() |
Looper |
getMainLooper() |
int |
getRecyclingMode() |
ResourceCache |
getResourceCache() |
ResourceResolver |
getResourceResolver() |
Resources |
getResources() |
java.lang.String |
getString(int resId) |
java.lang.String |
getString(int resId,
java.lang.Object... formatArgs) |
java.lang.CharSequence |
getText(int resId) |
<T> T |
getTreeProp(java.lang.Class<T> key) |
TreeProps |
getTreeProps() |
TreeProps |
getTreePropsCopy()
Obtain a copy of the tree props currently held by this context.
|
static boolean |
isIncrementalMountEnabled(ComponentContext c)
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.
|
protected boolean |
isParentTreePropsCloned() |
boolean |
isReconciliationEnabled() |
static boolean |
isVisibilityProcessingEnabled(ComponentContext c) |
static ComponentContext |
makeCopyForNestedTree(ComponentContext parentTreeContext)
Creates a new ComponentContext based on the given ComponentContext, propagating log tag,
logger, and tree props.
|
<E> EventHandler<E> |
newEventHandler(int id,
java.lang.Object[] params) |
TypedArray |
obtainStyledAttributes(int[] attrs,
int defStyleAttr) |
void |
putCachedValue(java.lang.Object cachedValueInputs,
java.lang.Object cachedValue) |
void |
setLayoutStateContextForTesting() |
protected void |
setParentTreePropsCloned(boolean isParentTreePropsCloned) |
void |
setTreeProps(TreeProps treeProps) |
void |
updateHookStateAsync(HookUpdater updateBlock)
EXPERIMENTAL - called to enqueue a HookUpdater that will update State that was created via
useState.
|
void |
updateStateAsync(StateContainer.StateUpdate stateUpdate,
java.lang.String attribution)
Notify the Component Tree that it needs to asynchronously perform a state update.
|
void |
updateStateLazy(StateContainer.StateUpdate stateUpdate) |
void |
updateStateSync(StateContainer.StateUpdate stateUpdate,
java.lang.String attribution)
Notify the Component Tree that it needs to synchronously perform a state update.
|
void |
updateStateWithTransition(StateContainer.StateUpdate stateUpdate,
java.lang.String attribution) |
static ComponentContext |
withComponentScope(ComponentContext parentContext,
Component scope,
java.lang.String globalKey)
Creates a new ComponentContext instance scoped to the given component and sets it on the
component.
|
static ComponentContext |
withComponentTree(ComponentContext context,
ComponentTree componentTree)
Creates a new ComponentContext instance and sets the
ComponentTree on the component. |
public static final InternalNode NULL_LAYOUT
public ComponentContext(Context context)
public ComponentContext(Context context, java.lang.String logTag, ComponentsLogger logger)
ComponentsLogger
for the type of events you can listen for.context
- Android context.logTag
- a log tag to be used with the logger.logger
- a lifecycle logger to be used.public ComponentContext(Context context, java.lang.String logTag, ComponentsLogger logger, TreeProps treeProps)
public ComponentContext(ComponentContext context, StateHandler stateHandler, TreeProps treeProps, LayoutStateContext layoutStateContext)
public static ComponentContext withComponentTree(ComponentContext context, ComponentTree componentTree)
ComponentTree
on the component.context
- context scoped to the parent componentcomponentTree
- component tree associated with the newly created contextpublic static ComponentContext withComponentScope(ComponentContext parentContext, Component scope, java.lang.String globalKey)
parentContext
- context scoped to the parent componentscope
- component associated with the newly created scoped contextpublic static ComponentContext makeCopyForNestedTree(ComponentContext parentTreeContext)
public void setLayoutStateContextForTesting()
public final Context getAndroidContext()
public final Context getApplicationContext()
public Resources getResources()
public ResourceResolver getResourceResolver()
public final Looper getMainLooper()
public java.lang.CharSequence getText(int resId)
public java.lang.String getString(int resId)
public java.lang.String getString(int resId, java.lang.Object... formatArgs)
public int getColor(int id)
public Component getComponentScope()
public java.lang.String getGlobalKey()
public EventHandler<ErrorEvent> getErrorEventHandler()
public com.facebook.litho.ComponentTree.LayoutStateFuture getLayoutStateFuture()
public void updateStateSync(StateContainer.StateUpdate stateUpdate, java.lang.String attribution)
stateUpdate
- state update to performpublic void updateStateAsync(StateContainer.StateUpdate stateUpdate, java.lang.String attribution)
stateUpdate
- state update to performpublic void updateStateWithTransition(StateContainer.StateUpdate stateUpdate, java.lang.String attribution)
public void updateStateLazy(StateContainer.StateUpdate stateUpdate)
public void updateHookStateAsync(HookUpdater updateBlock)
public void applyLazyStateUpdatesForContainer(StateContainer container)
public TypedArray obtainStyledAttributes(int[] attrs, int defStyleAttr)
public java.lang.String getLogTag()
public ComponentsLogger getLogger()
public void setTreeProps(TreeProps treeProps)
public TreeProps getTreeProps()
protected boolean isParentTreePropsCloned()
protected void setParentTreePropsCloned(boolean isParentTreePropsCloned)
public <T> T getTreeProp(java.lang.Class<T> key)
public TreeProps getTreePropsCopy()
public int getLayoutVersion()
public ResourceCache getResourceCache()
public <E> EventHandler<E> newEventHandler(int id, java.lang.Object[] params)
public java.lang.Object getCachedValue(java.lang.Object cachedValueInputs)
public void putCachedValue(java.lang.Object cachedValueInputs, java.lang.Object cachedValue)
public static boolean isIncrementalMountEnabled(ComponentContext c)
public static boolean isVisibilityProcessingEnabled(ComponentContext c)
public boolean isReconciliationEnabled()
public LayoutStateContext getLayoutStateContext()
public int getRecyclingMode()