public class ComponentTree extends Object
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.
|
Modifier and Type | Field and Description |
---|---|
static int |
INVALID_ID |
protected int |
mId |
Modifier | Constructor and Description |
---|---|
protected |
ComponentTree(ComponentTree.Builder builder) |
Modifier and Type | Method and Description |
---|---|
StateHandler |
acquireStateHandler()
Provides a new instance from the StateHandler pool that is initialized with the information
from the StateHandler currently held by the ComponentTree.
|
protected com.facebook.litho.LayoutState |
calculateLayoutState(Object lock,
ComponentContext context,
Component root,
int widthSpec,
int heightSpec,
boolean diffingEnabled,
com.facebook.litho.LayoutState previousLayoutState,
TreeProps treeProps,
int source,
String extraAttribution) |
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. |
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,
Component.Builder<?> root) |
static ComponentTree.Builder |
create(ComponentContext context,
Component root) |
static int |
generateComponentTreeId() |
protected com.facebook.litho.LayoutState |
getBackgroundLayoutState() |
ComponentContext |
getContext() |
LithoView |
getLithoView() |
ComponentTree.NewLayoutStateReadyListener |
getNewLayoutStateReadyListener() |
boolean |
hasCompatibleLayout(int widthSpec,
int heightSpec) |
boolean |
hasMounted()
Whether this ComponentTree has been mounted at least once.
|
boolean |
isIncrementalMountEnabled()
Returns whether incremental mount is enabled or not in this component.
|
boolean |
isIncrementalMountOnPreDraw()
Whether this component does incremental mount in onPreDraw
|
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 |
setNewLayoutStateReadyListener(ComponentTree.NewLayoutStateReadyListener listener) |
void |
setRoot(Component rootComponent)
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 rootComponent) |
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 |
updateLayoutThreadHandler(LayoutHandler layoutThreadHandler)
Provide custom
LayoutHandler . |
public static final int INVALID_ID
protected final int mId
protected ComponentTree(ComponentTree.Builder builder)
public static ComponentTree.Builder create(ComponentContext context, Component.Builder<?> root)
public static ComponentTree.Builder create(ComponentContext context, Component root)
protected com.facebook.litho.LayoutState getBackgroundLayoutState()
public boolean hasMounted()
public void setNewLayoutStateReadyListener(ComponentTree.NewLayoutStateReadyListener listener)
public void updateLayoutThreadHandler(LayoutHandler layoutThreadHandler)
LayoutHandler
. If null is provided default one will be used for layouts.public ComponentTree.NewLayoutStateReadyListener getNewLayoutStateReadyListener()
public boolean hasCompatibleLayout(int widthSpec, int heightSpec)
public boolean isIncrementalMountEnabled()
public boolean isIncrementalMountOnPreDraw()
public void setRoot(Component rootComponent)
public void setRootAsync(Component rootComponent)
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 LithoView getLithoView()
LithoView
associated with this ComponentTree if any.public StateHandler acquireStateHandler()
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 boolean isReleased()
public ComponentContext getContext()
protected com.facebook.litho.LayoutState calculateLayoutState(Object lock, ComponentContext context, Component root, int widthSpec, int heightSpec, boolean diffingEnabled, com.facebook.litho.LayoutState previousLayoutState, TreeProps treeProps, int source, String extraAttribution)
public static int generateComponentTreeId()