public class ComponentContext extends Object
Modifier and Type | Field and Description |
---|---|
static InternalNode |
NULL_LAYOUT |
Constructor and Description |
---|
ComponentContext(ComponentContext context,
StateHandler stateHandler,
HooksHandler hooksHandler,
TreeProps treeProps,
com.facebook.litho.LayoutState.LayoutStateContext layoutStateContext) |
ComponentContext(ComponentContext context,
StateHandler stateHandler,
TreeProps treeProps,
com.facebook.litho.LayoutState.LayoutStateContext layoutStateContext) |
ComponentContext(Context context) |
ComponentContext(Context context,
com.facebook.litho.LayoutState.LayoutStateContext layoutStateContext) |
ComponentContext(Context context,
StateHandler stateHandler) |
ComponentContext(Context context,
String logTag,
ComponentsLogger logger)
Constructor that can be used to receive log data from components.
|
ComponentContext(Context context,
String logTag,
ComponentsLogger logger,
StateHandler stateHandler,
HooksHandler hooksHandler,
TreeProps treeProps) |
ComponentContext(Context context,
String logTag,
ComponentsLogger logger,
StateHandler stateHandler,
TreeProps treeProps) |
ComponentContext(Context context,
String logTag,
ComponentsLogger logger,
TreeProps treeProps) |
Modifier and Type | Method and Description |
---|---|
void |
applyLazyStateUpdatesForContainer(StateContainer container) |
Context |
getAndroidContext() |
Context |
getApplicationContext() |
Object |
getCachedValue(Object cachedValueInputs) |
int |
getColor(int id) |
Component |
getComponentScope() |
com.facebook.litho.ComponentTree.LayoutStateFuture |
getLayoutStateFuture() |
int |
getLayoutVersion() |
ComponentsLogger |
getLogger() |
String |
getLogTag() |
Looper |
getMainLooper() |
int |
getRecyclingMode() |
ResourceCache |
getResourceCache() |
ResourceResolver |
getResourceResolver() |
Resources |
getResources() |
String |
getString(int resId) |
String |
getString(int resId,
Object... formatArgs) |
CharSequence |
getText(int resId) |
<T> T |
getTreeProp(Class<T> key) |
protected 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) |
<E> EventHandler<E> |
newEventHandler(int id,
Object[] params) |
TypedArray |
obtainStyledAttributes(int[] attrs,
int defStyleAttr) |
void |
putCachedValue(Object cachedValueInputs,
Object cachedValue) |
void |
setLayoutStateContextForTesting() |
protected void |
setParentTreePropsCloned(boolean isParentTreePropsCloned) |
protected void |
setTreeProps(TreeProps treeProps) |
<T> void |
updateHookStateAsync(HookUpdater<T> updateBlock)
EXPERIMENTAL - called to enqueue a HookUpdater that will update State that was created via
useState.
|
void |
updateStateAsync(StateContainer.StateUpdate stateUpdate,
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,
String attribution)
Notify the Component Tree that it needs to synchronously perform a state update.
|
void |
updateStateWithTransition(StateContainer.StateUpdate stateUpdate,
String attribution) |
static ComponentContext |
withComponentScope(ComponentContext context,
Component scope)
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, com.facebook.litho.LayoutState.LayoutStateContext layoutStateContext)
public ComponentContext(Context context, StateHandler stateHandler)
public ComponentContext(Context context, 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, String logTag, ComponentsLogger logger, TreeProps treeProps)
public ComponentContext(Context context, String logTag, ComponentsLogger logger, StateHandler stateHandler, TreeProps treeProps)
public ComponentContext(Context context, String logTag, ComponentsLogger logger, StateHandler stateHandler, HooksHandler hooksHandler, TreeProps treeProps)
public ComponentContext(ComponentContext context, StateHandler stateHandler, TreeProps treeProps, com.facebook.litho.LayoutState.LayoutStateContext layoutStateContext)
public ComponentContext(ComponentContext context, StateHandler stateHandler, HooksHandler hooksHandler, TreeProps treeProps, com.facebook.litho.LayoutState.LayoutStateContext layoutStateContext)
public void setLayoutStateContextForTesting()
public final Context getAndroidContext()
public final Context getApplicationContext()
public Resources getResources()
public ResourceResolver getResourceResolver()
public final Looper getMainLooper()
public CharSequence getText(int resId)
public String getString(int resId)
public int getColor(int id)
public Component getComponentScope()
public com.facebook.litho.ComponentTree.LayoutStateFuture getLayoutStateFuture()
public void updateStateSync(StateContainer.StateUpdate stateUpdate, String attribution)
stateUpdate
- state update to performpublic void updateStateAsync(StateContainer.StateUpdate stateUpdate, String attribution)
stateUpdate
- state update to performpublic void updateStateWithTransition(StateContainer.StateUpdate stateUpdate, String attribution)
public void updateStateLazy(StateContainer.StateUpdate stateUpdate)
public <T> void updateHookStateAsync(HookUpdater<T> updateBlock)
public void applyLazyStateUpdatesForContainer(StateContainer container)
public TypedArray obtainStyledAttributes(int[] attrs, int defStyleAttr)
public String getLogTag()
public ComponentsLogger getLogger()
protected void setTreeProps(TreeProps treeProps)
protected TreeProps getTreeProps()
protected boolean isParentTreePropsCloned()
protected void setParentTreePropsCloned(boolean isParentTreePropsCloned)
public <T> T getTreeProp(Class<T> key)
public TreeProps getTreePropsCopy()
public int getLayoutVersion()
public ResourceCache getResourceCache()
public <E> EventHandler<E> newEventHandler(int id, Object[] params)
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 context, Component scope)
context
- context scoped to the parent componentscope
- component associated with the newly created scoped contextpublic static boolean isIncrementalMountEnabled(ComponentContext c)
public static boolean isVisibilityProcessingEnabled(ComponentContext c)
public boolean isReconciliationEnabled()
public int getRecyclingMode()