Package-level declarations
Types
A list of all roles used for accessibility. There is no API for these in Android yet, so roles are currently based off of the class being rendered. These roles are defined by Google's TalkBack screen reader, and this list should be kept up to date with their implementation.
This type of key is used to represent an attribute that reflects an Action (such as click, long click, etc).
Utilities for animations debug.
This abstraction allows us to retrieve a LifecycleOwner. This class is meant to be used to identify the closest LifecycleOwner and associate it to the ComponentTree.
This LithoVisibilityEventsController implementation dispatches to the registered observers the lifecycle state changes triggered by the provided LifecycleOwner. For example, if a Fragment is passed as param, the observers will be registered to listen to all of the fragment's lifecycle state changes.
Interface for something (e.g. a Component or a useEffect registration) which should receive callbacks when it is attached/detached from the tree.
Manages dispatching attach/detach events to a set of Attachable.
This abstraction is used as an identifier for a given attribute of type T. Attributes are used for testing purposes, allowing the clients to filter and assert on Component according to them.
Defines an abstraction that knows how to store attributes.
Simple holder which allows to store and retrieve attributes.
A Batched State Update Strategy will define when do we schedule a final state update and corresponding layout calculation, so that we can enqueue the most reasonable number of state updates without incurring with an excessive number of layout calculations.
An implementation of working range that uses offset to define the upper bound and the lower boundary. If the position is inside the boundary, it's in the range, otherwise it's out of the range.
Defines a single tree prop, i.e. a mapping from type to concrete instance of that type that is visible to the subtree, to be used with TreePropProvider.
Provides util methods for common collection patterns.
A Component that renders its children in a column.
Internal class that holds props that are common to all Components.
Focus change listener that triggers its underlying event handler.
Represents a Component's computed layout state. The computed bounds will be used by the framework to define the size and position of the component's mounted android.view.Views and android.graphics.drawable.Drawables returned by com.facebook.litho.annotations.OnMeasure.
Long click listener that triggers its underlying event handler.
The result of a Component#resolveWithResult call. This will hold the LithoNode this Component resolved to as well as CommonProps of this component.
The implicit receiver for KComponent.render call. This class exposes the ability to use hooks, like useState, and convenience functions, like dp.
This is intended as a hook into android.util.Log
, but allows you to provide your own functionality. Use it as ComponentsReporter.emitMessage(level, message);
As a default, it simply calls android.util.Log
(see DefaultComponentsReporter). You may supply your own with ComponentsReporter.provide.
This is intended as a hook into android.os.Trace
, but allows you to provide your own functionality. Use it as
Touch listener that triggers its underlying event handler.
This is used as a listener for events that happen on the scope of a given ComponentTree. These events can be related with both the render
UI pipeline, or with the view-side events created by rendercore in the LithoView that is associated to the ComponentTree to which this listener observes.
Helper class in charge of dumping the component hierarchy related to a provided ComponentContext
Marker for the Litho container component DSL. This makes sure that when we have scope-specific functions like child()
to add children, they can only apply to the closest receiver annotated with ContainerDsl.
Pre-allocate the mount content of all MountSpec in the given ComponentTree.
A DebugComponent represents a node in Litho's component hierarchy. DebugComponent removes the need to worry about implementation details of whether a node is represented by a [ ] or a ComponentLayout. The purpose of this class is for tools such as Flipper's UI inspector to be able to easily visualize a component hierarchy without worrying about implementation details of Litho.
Describes DebugComponents for use in testing and debugging. Note that com.facebook.litho.config.ComponentsConfiguration#isEndToEndTestRun must be enabled in order for this data to be collected.
DebugHierarchy provides a light(er) weight way to track and access information about the component parentage of a given com.facebook.rendercore.MountItem. For a given com.facebook.rendercore.MountItem, it provides access to a linked list of Class objects representing the class of the Component and each of it's hierarchy parents.
A DebugLayoutNode is a wrapper around InternalNode which allows debug tools to inspect and mutate internal nodes without making InternalNode a public class. This class should never be used in production and only for building debug tools.
Default implementation of ErrorEvent handler.
An event handler that takes two event handlers and calls both of them when an event is dispatched.
Defines a tooltip that can be passed to the ComponentTree to be anchored to a component. The framework takes care of finding the position where the tooltip needs to anchored.
Allows a new DynamicValue to be derived from an existing DynamicValue, with modifications applied.
Represents a diff between two T
values. It should be used when defining the ShouldUpdate callback in a ComponentSpec and may be used in OnCreateTransition to define animations based on incoming changes. A Diff holds the previous and next value for a specific Prop or State for a ComponentSpec.
Static class containing a factory method for creating a matrix to apply to a drawable.
Takes care of dynamic Props
Class represents a DynamicValue, and provides users with ability to change the value, by exposing one public method set It also allows attaching listeners (package level access), and takes care of notifying them when the held value changes.
A component which renders nothing.
An interfaced used by ComponentContext to notify the holder of a Litho hierarchy that as a result of error handling the root of the tree should change to a Litho component representing the error.
This class is an error event handler that clients can optionally set on a ComponentTree to gracefully handle uncaught/unhandled exceptions thrown from the framework while resolving a layout.
A class implementing this fun interface will expose a method to dispatch an com.facebook.litho.annotations.Event given an EventHandler.
Plugin style that can be used for instrument before & after the event is dispatched by EventDispatcher.dispatchOnEvent
Holds onto the mutable data used to dispatch an event. This data is kept up-to-date with the latest version of the owning component or section by EventHandlersController.
Controller which makes sure EventHandler instances are bound to the latest instance of the Component/Section that created them.
Allows a top-down communication with a component and its immediate parent. The component must be able to handle com.facebook.litho.annotations.OnTrigger events in order to accept an EventTrigger.
Keeps all valid instances of EventTrigger from the hierarchy when the layout is completed
A class implementing this fun interface wll expose a method annotated with com.facebook.litho.annotations.OnTrigger to accept an com.facebook.litho.annotations.Event given an EventTrigger
A LithoHandler
implementation that runs all layout computations against the provided Executor
. This LithoHandler
can be used in apps that have a well established threading model and need to run layout against one of their already available executors.
The implicit receiver for the trailing lambda on ResourcesScope.Column or ResourcesScope.Row. The receiver gives the ability to add children to this container.
Create multiple FocusOrderModels, which can to be used to specify a focus traversal order.
Instances of this class are used to uniquely identify Components for triggering external events including showing a LithoTooltip or triggering an com.facebook.litho.annotations.OnTrigger event.
A class implementing this interface will expose a method to retrieve an EventDispatcher.
A class implementing this fun interface will expose a method to record all the EventTrigger into a EventTriggersContainer
An fun interface that a mountable view can extend which informs that this mountable content has other LithoView children. This is used to make sure to unmount this view's children when unmounting this view itself.
Interface for a block of code that will initialize a hook value.
EXPERIMENTAL - fun interface for a block of code that will update state created with useState. See KState.kt for more details.
A specific MountContentPool for HostComponent - needed to do correct recycling with things like duplicateParentState.
A UI element that contains simple resource drawables.
The InitialStateContainer is a lookaside table used by a ComponentTree to create initial states for Components. The idea is that the onCreateInitialState result for each component will be cached and stored here so that we can guarantee it's not called multiple times on multiple threads. We keep the initial states cached as long as there is a layout happening for the ComponentTree. As soon as we detect that all in-flights layout have terminated we can clean up the initial states cache.
Container for inter-stage props. A component with inter-stage props will generate its own InterStagePropsContainer implementation which will hold fields for each inter-stage prop specified.
Base class for Kotlin Components.
The StateContainer implementation for Kotlin components. It tracks all the state defined by useState calls for the same component. See KState for how this is being used. This is a purely immutable class and it exposes utilities to create a new instance with either a new piece of state or by changing the value at a given index
The main role of LayoutState is to hold the output of layout calculation. This includes mountable outputs and visibility outputs. A centerpiece of the class is LithoReducer#setSizeAfterMeasureAndCollectResults(ComponentContext, LithoLayoutContext, LayoutState) which prepares the before-mentioned outputs based on the provided LithoNode for later use in MountState.
Litho's implementation of the AnimatableItem required by the TransitionsExtension to power animations. This object should NOT be used to inform the should update during mounting, therefore it should NOT be used to host any such information.
Simple wrapper of GestureDetector to be used in Litho lifecycle methods. Using this class ensures that UI Thread Handler is used for detecting gestures.
Wraps objects which should only be available for the duration of a LayoutState, to access them in other classes such as ComponentContext during layout state calculation. When the layout calculation finishes, the LayoutState reference is nullified. Using a wrapper instead of passing the instances directly helps with clearing out the reference from all objects that hold on to it, without having to keep track of all these objects to clear out the references.
This object will host the data associated with the component which is generated during the measure pass, for example: the InterStagePropsContainer, and the UpdateState. It will be created in LayoutResult#calculateLayout(LayoutContext, int, int). This object will be returned by LayoutResult#getLayoutData(), then written to the layout data in RenderTreeNode during reduce.
A data structure that holds the result of Litho layout phase.
This is the default implementation of a LayoutResult for Litho.
Exception class used to add additional Litho metadata to a crash.
This class hosts any extra mount data related to MountItem.
LithoNode is the Node implementation of Litho.
A class that represents a Primitive with Style that should be applied to the PrimitiveComponent.
An implementation of BaseMountingView that can mount a LayoutState without the need for a ComponentTree
Logger for tracking Litho events happening during startup.
Represents a pointer to the Tree that a ComponentContext is attached to
Helper class to access metadata from LithoView that is relevant during end to end tests. In order for the data to be collected, ComponentsConfiguration#isEndToEndTestRun must be enabled.
Manages a Litho visibility events and informs subscribed LithoVisibilityEventsListener when a visibility state changes.
Default LithoVisibilityEventsController implementation. Defines the standard state changes for a Litho ComponentTree. A custom LithoVisibilityEventsController implementation can change the lifecycle state but delegate to this to handle the effects of the state change. See an example of how this facilitates a custom lifecycle implementation in AOSPLithoVisibilityEventsController.
Can observe lifecycle changes that a LithoVisibilityEventsController goes through.
This class provides utilities for extracting information through ComponentsLogger#getExtraAnnotations(TreeProps) and transforming them so they can be logged.
A Drawable that wraps another drawable.
An utility class to verify that an old measured size is still compatible to be used with a new measureSpec.
Read & write layout result cache used during render phase for caching measured results that happen during component-measure. This cache can be accessed via components or litho-nodes.
An interfaced used by ComponentContext to access the root view on which a hierarchy is mounted. This interface needs to be passed in the ComponentContext when it's built.
This RenderUnit encapsulates a Litho output to be mounted using Render Core.
The NestedLithoTree should be used to render Litho components in a container, say a Primitive like a ScrollView or when embedded Litho hierarchies in other RC framework hierarchies.
MountExtension to ensure that content with nested LithoViews is properly clearing those LithoViews when the item is unmounted. Since this should only happen when unmounting an item and not when it's being updated, shouldUpdateItem is not overridden (defaulting to super implementation which returns false).
This class is a placeholder for the unresolved layout and result of a Components which implement the com.facebook.litho.annotations.OnCreateLayoutWithSizeSpec.The TreePropContainer, padding and border width properties and held separately so that they can be copied into the actual nested tree layout before measuring it.
This is an output only NestedTreeHolderResult; this is created by a NestedTreeHolder.
A helper class that defines a configurable sizes for Pooling.
Interface defining a result calculated from a TreeFuture that could be interrupted, and therefore be partial (and resumed on the UI thread).
Base class for Kotlin primitive components. This class encapsulates some of the Mount Spec APIs. All Kotlin primitive components must extend this class.
The implicit receiver for PrimitiveComponent.render call.
The result of a Component#render call. This will be the Component this component rendered to, potentially as well as other non-Component metadata that resulted from that call, such as transitions that should be applied.
Keeps track of the last mounted @Prop/@State a component was rendered with for components that care about them (currently, this is just for ComponentSpecs that use Diff's of props in any of their lifecycle methods).
Class that handles generation of unique IDs for RenderUnits for a given ComponentTree. The ID generation uses the component key to create an ID, and creates unique IDs for any components under the same ComponentTree.
TODO(T137275959)
The receiver for KComponent methods which need to access resources and widgets like Row, Column, and Text. This class exposes the ability to access functions defined in Resources like stringRes/drawableRes etc.
Takes a component and returns a new component that it is wrapped in. Used to create a common root wrapper in ComponentTree.
A Component that renders its children in a row.
LithoVisibilityEventsController implementation that can be used to subscribe a nested ComponentTree to listen to state changes of the lifecycle provider that the parent ComponentTree is also subscribed to.
Implemented by the class used to store state within both Components and Sections to store state.
Holds information about the current State of the components in a Component Tree.
StateUpdater lets a Component rendered with a scoped ComponentContext interact with Litho's state. An implementation of StateUpdater is responsible for collecting state update operations and schedule a new Resolve/Layout step to occur. The default implementation of StateUpdater is ComponentTree, but it might be useful to implement this interface when integrating Litho in different rendering frameworks where it's not desirable for Litho to control the resolve/layout/commit process.
StateUpdaterDelegator is responsible for holding reference to the right StateUpdater that will be used during creation of ComponentTree
Used to represent the value of a Component's State. Must be used to pass State as parameter in methods annotated with @OnUpdateState.
Backwards compatibility to allow Java code to define Styles used by Kotlin components
An interface for a View which supports setting and unsetting its transform pivot, even on pre-API 28 (P) devices.
A Component that wraps another component for testing purposes. This component has a lifecycle that doesn't override any methods except for isEquivalentTo().
Holds information about a TestOutput.
This should be only used with the deprecated DiffNode based testing infrastructure. This class hosts a test implementation of create and resolve layout. The implementation only resolves the immediate subcomponents of the component. The implementation details of this class should be kept in sync with LayoutState if the existing tests written with the deprecated testing infrastructure are relevant.
Stores information about a Component which is only available when tests are run. TestOutputs are calculated in LayoutState and transformed into TestItems while mounting.
An UI Element that contains textual content. This element can have more than one textual content. For example, one Mountable wrapping a complex custom view can have multiple text views, and therefore, multiple TextContent.Item
ThreadTracingRunnable tries to help debugging crashes happening across threads showing the stacktrace of the crash origin which scheduled this runnable.
Thread assertion utilities.
Specify a position to anchor a DeprecatedLithoTooltip on a component.
Any interface for mounted items that need to capture motion events from its ComponentHost.
Compound touch delegate that forward touch events to recyclable inner touch delegates.
Base class that wraps a FutureTask to allow calculating the same result across threads.
A data structure to store tree props.
Defines a single tree prop override. Unlike ClassValuePair there can be multiple TreePropValuePair with the same corresponding class.
Interface for the onUnbindDynamic function: use onUnbindDynamic to define the cleanup function for your dynamic values.
A component that can wrap a view using a ViewBinder class to bind the view and a ViewCreator to create the mount contents. This component will have a different recycle pool per ViewCreator instance.
Components should implement an event of this type in order to be notified when keyboard focus changes on any virtual views implemented.
A container that stores working range related information. It provides two major methods: a register method to store a working range with a component, and a dispatch method that dispatches event to components to trigger their delegated methods.
A handler that stores the range status of components with given working range.
Utility class for wrapping an existing Component. This is useful for adding further CommonProps to an already created component.
A wrapper around YogaNode that implements LithoLayoutOutput, which will be used internally by LithoYogaLayoutFunction.
Functions
Constructs a new Column without any children.
Constructs a new Column. Add children by using FlexboxContainerScope.child or FlexboxContainerScope.children:
Resolve a dimen resource ID as a Dimen value.
Return a android.graphics.drawable.Drawable for a ColorInt value as a Drawable instance.
Returns the instance registered for the type T in this hierarchy, and null
if no value was registered. Tree props are registered for a sub-hierarchy via TreePropProvider or com.facebook.litho.annotations.OnCreateTreeProp in the Spec API.
Backwards compatibility for a Kotlin Component to accept a Style and apply it to a Java Spec Component. Using this builder method is the equivalent of setting all common props the Style defines.
Returns a Primitive, and the ResolveResult that renders an embedded Litho component. This API should only be used when embedding Litho in a non Litho RC framework, like Bloks. This API accepts the updated state; this API should only be used if the client framework applies state updates before resolving the component to a Primitive.
Returns a Primitive, and the ResolveResult that renders an embedded Litho component. This API should only be used when embedding Litho in a non Litho RC framework, like Bloks. This API accepts the current state and pending state updates.
Same as TreePropProvider, but accepts a lambda that may return a nullable component, in which case it'll return null itself.
Defines a cleanup function to be invoked when the owning Component is detached or the deps in useEffect change.
Utility for preloading classes that should be loaded early but may not be accessible outside of Litho.
Returns the instance registered for the type T in this hierarchy, throws if no value was registered. Tree props are registered for a sub-hierarchy via TreePropProvider or com.facebook.litho.annotations.OnCreateTreeProp in the Spec API.
Constructs a new Column without any children.
Constructs a new Row. Add children by using FlexboxContainerScope.child or FlexboxContainerScope.children:
A component which provides one or more TreeProp values to the given child hierarchy. A tree prop is a mapping from a TreeProp key object to an value of a corresponding type which is accessible throughout the entire subtree where it's defined.
A component which provides one or more tree props to the given child hierarchy. A tree prop is a mapping from a type to an instance of that type which is accessible throughout the entire subtree where it's defined.
Create a CachedValue variable within a Component. The calculator will provide the calculated value if it hasn't already been calculated or if the inputs have changed since the previous calculation.
useCallback allows a parent to pass a child component a callback which: 1) maintains referential equality across multiple layout passes 2) is updated to have the latest parent props and state, even if the child doesn't re-render.
1-parameter overload of useCallback: refer to docs there.
2-parameter overload of useCallback: refer to docs there.
3-parameter overload of useCallback: refer to docs there.
4-parameter overload of useCallback: refer to docs there.
5-parameter overload of useCallback: refer to docs there.
6-parameter overload of useCallback: refer to docs there.
7-parameter overload of useCallback: refer to docs there.
Registers a callback to perform side-effects when this Component is attached/detached from the tree.
Registers a callback to perform error handling for exceptions that might happen in child components down in the tree.
This hook creates a set of references, one for each focusable component that can be used for changing the default focus order. Use with Style.focusOrder
Declares a mutable, main-thread confined reference that will be persisted across renders with an initial value provided by the initializer. It's similar to useState, except that the returned reference is mutable and updating it will not cause a re-render.