public class ComponentTree extends Object
The usual use case for ComponentTree
is:
ComponentTree component = ComponentTree.create(context, MyComponent.create());
myHostView.setRoot(component);
Modifier and Type | Class and Description |
---|---|
static class |
ComponentTree.Builder
A builder class that can be used to create a
ComponentTree . |
static interface |
ComponentTree.MeasureListener |
static interface |
ComponentTree.NewLayoutStateReadyListener
Listener that will be notified when a new LayoutState is computed and ready to be committed to
this ComponentTree.
|
static interface |
ComponentTree.RecyclingMode |
Modifier and Type | Field and Description |
---|---|
static int |
INVALID_ID |
protected int |
mId |
static int |
STATE_UPDATES_IN_LOOP_THRESHOLD |
Modifier | Constructor and Description |
---|---|
protected |
ComponentTree(ComponentTree.Builder builder) |
Modifier and Type | Method and Description |
---|---|
HooksHandler |
acquireHooksHandlerIfNecessary() |
StateHandler |
acquireStateHandler()
Provides a new instance from the StateHandler pool that is initialized with the information
from the StateHandler currently held by the ComponentTree.
|
void |
addMeasureListener(ComponentTree.MeasureListener measureListener)
The provided measureListener will be called when a valid layout is commited.
|
void |
cancelLayoutAndReleaseTree() |
void |
checkWorkingRangeAndDispatch(int position,
int firstVisibleIndex,
int lastVisibleIndex,
int firstFullyVisibleIndex,
int lastFullyVisibleIndex)
Check if the any child components stored in
LayoutState have entered/exited the working
range, and dispatch the event to trigger the corresponding registered methods. |
void |
clearMeasureListener(ComponentTree.MeasureListener measureListener) |
RenderState |
consumePreviousRenderState()
Takes ownership of the
RenderState object from this ComponentTree - this allows the
RenderState to be persisted somewhere and then set back on another ComponentTree using the
ComponentTree.Builder . |
static ComponentTree.Builder |
create(ComponentContext context) |
static ComponentTree.Builder |
create(ComponentContext context,
Component.Builder<?> root) |
static ComponentTree.Builder |
create(ComponentContext context,
Component root) |
static int |
generateComponentTreeId() |
LayoutState |
getCommittedLayoutState() |
ComponentContext |
getContext() |
LithoHandler |
getLayoutThreadHandler() |
LithoView |
getLithoView() |
ComponentsLogger |
getLogger() |
String |
getLogTag() |
ComponentTree.NewLayoutStateReadyListener |
getNewLayoutStateReadyListener() |
int |
getRecyclingMode()
Returns the recycling mode.
|
String |
getSimpleName() |
boolean |
hasCompatibleLayout(int widthSpec,
int heightSpec) |
boolean |
hasMounted()
Whether this ComponentTree has been mounted at least once.
|
boolean |
isFirstMount() |
boolean |
isIncrementalMountEnabled()
Returns whether incremental mount is enabled or not in this component.
|
boolean |
isReconciliationEnabled() |
boolean |
isReleased() |
void |
release()
The contract is that in order to release a ComponentTree, you must do so from the main thread,
or guarantee that it will never be accessed from the main thread again.
|
void |
setIsFirstMount(boolean isFirstMount) |
void |
setNewLayoutStateReadyListener(ComponentTree.NewLayoutStateReadyListener listener) |
void |
setRoot(Component root)
Update the root component.
|
void |
setRootAndSizeSpec(Component root,
int widthSpec,
int heightSpec)
Compute a new layout with the given component root and sizes
|
void |
setRootAndSizeSpec(Component root,
int widthSpec,
int heightSpec,
Size output) |
void |
setRootAndSizeSpec(Component root,
int widthSpec,
int heightSpec,
Size output,
TreeProps treeProps) |
void |
setRootAndSizeSpecAsync(Component root,
int widthSpec,
int heightSpec)
Compute asynchronously a new layout with the given component root and sizes
|
void |
setRootAndSizeSpecAsync(Component root,
int widthSpec,
int heightSpec,
TreeProps treeProps)
Compute asynchronously a new layout with the given component root, sizes and stored TreeProps.
|
void |
setRootAsync(Component root) |
void |
setSizeSpec(int widthSpec,
int heightSpec)
Update the width/height spec.
|
void |
setSizeSpec(int widthSpec,
int heightSpec,
Size output)
Same as
setSizeSpec(int, int) but fetches the resulting width/height in the given
Size . |
void |
setSizeSpecAsync(int widthSpec,
int heightSpec) |
void |
setVersionedRootAndSizeSpec(Component root,
int widthSpec,
int heightSpec,
Size output,
TreeProps treeProps,
int externalRootVersion) |
void |
updateLayoutThreadHandler(LithoHandler layoutThreadHandler)
Provide custom
LithoHandler . |
public static final int INVALID_ID
public static final int STATE_UPDATES_IN_LOOP_THRESHOLD
protected final int mId
protected ComponentTree(ComponentTree.Builder builder)
public static ComponentTree.Builder create(ComponentContext context)
public static ComponentTree.Builder create(ComponentContext context, Component.Builder<?> root)
public static ComponentTree.Builder create(ComponentContext context, Component root)
public void addMeasureListener(ComponentTree.MeasureListener measureListener)
measureListener
- public void clearMeasureListener(ComponentTree.MeasureListener measureListener)
public LayoutState getCommittedLayoutState()
public boolean hasMounted()
public boolean isFirstMount()
public void setIsFirstMount(boolean isFirstMount)
public void setNewLayoutStateReadyListener(ComponentTree.NewLayoutStateReadyListener listener)
public void updateLayoutThreadHandler(LithoHandler layoutThreadHandler)
LithoHandler
. If null is provided default one will be used for layouts.public LithoHandler getLayoutThreadHandler()
public ComponentTree.NewLayoutStateReadyListener getNewLayoutStateReadyListener()
public boolean hasCompatibleLayout(int widthSpec, int heightSpec)
public boolean isIncrementalMountEnabled()
public int getRecyclingMode()
for details of different modes
public boolean isReconciliationEnabled()
public void setRoot(Component root)
public void setRootAsync(Component root)
public void checkWorkingRangeAndDispatch(int position, int firstVisibleIndex, int lastVisibleIndex, int firstFullyVisibleIndex, int lastFullyVisibleIndex)
LayoutState
have entered/exited the working
range, and dispatch the event to trigger the corresponding registered methods.public void setSizeSpec(int widthSpec, int heightSpec)
public void setSizeSpec(int widthSpec, int heightSpec, Size output)
setSizeSpec(int, int)
but fetches the resulting width/height in the given
Size
.public void setSizeSpecAsync(int widthSpec, int heightSpec)
public void setRootAndSizeSpecAsync(Component root, int widthSpec, int heightSpec)
public void setRootAndSizeSpecAsync(Component root, int widthSpec, int heightSpec, TreeProps treeProps)
public void setRootAndSizeSpec(Component root, int widthSpec, int heightSpec)
public void setRootAndSizeSpec(Component root, int widthSpec, int heightSpec, Size output)
public void setRootAndSizeSpec(Component root, int widthSpec, int heightSpec, Size output, TreeProps treeProps)
public void setVersionedRootAndSizeSpec(Component root, int widthSpec, int heightSpec, Size output, TreeProps treeProps, int externalRootVersion)
public LithoView getLithoView()
LithoView
associated with this ComponentTree if any. Since this is modified
on the main thread, it is racy to get the current LithoView off the main thread.public StateHandler acquireStateHandler()
public HooksHandler acquireHooksHandlerIfNecessary()
public RenderState consumePreviousRenderState()
RenderState
object from this ComponentTree - this allows the
RenderState to be persisted somewhere and then set back on another ComponentTree using the
ComponentTree.Builder
. See RenderState
for more information on the purpose of this object.public void release()
public String getSimpleName()
public boolean isReleased()
public ComponentContext getContext()
public ComponentsLogger getLogger()
public String getLogTag()
public void cancelLayoutAndReleaseTree()
public static int generateComponentTreeId()