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.DiffNode diffNode,
int source) |
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 |
isIncrementalMountEnabled()
Returns whether incremental mount is enabled or not in this component.
|
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 |
setRootAndSizeSpecAsync(Component root,
int widthSpec,
int heightSpec)
Compute asynchronously a new layout with the given component root and sizes
|
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) |
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, @NonNull Component root)
@Nullable protected com.facebook.litho.LayoutState getBackgroundLayoutState()
public void setNewLayoutStateReadyListener(ComponentTree.NewLayoutStateReadyListener listener)
public ComponentTree.NewLayoutStateReadyListener getNewLayoutStateReadyListener()
public boolean hasCompatibleLayout(int widthSpec, int heightSpec)
public boolean isIncrementalMountEnabled()
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 setRootAndSizeSpec(Component root, int widthSpec, int heightSpec)
public void setRootAndSizeSpec(Component root, int widthSpec, int heightSpec, Size output)
@Nullable 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(@Nullable Object lock, ComponentContext context, Component root, int widthSpec, int heightSpec, boolean diffingEnabled, @Nullable com.facebook.litho.DiffNode diffNode, int source)
public static int generateComponentTreeId()