public static class RecyclerBinder.Builder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_RANGE_RATIO |
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
RecyclerBinder.Builder |
acquireStateHandlerOnRelease(boolean acquireStateHandlerOnRelease)
Defaults to true.
|
RecyclerBinder.Builder |
asyncInsertLayoutHandler(RunnableHandler handler) |
RecyclerBinder |
build(ComponentContext c) |
RecyclerBinder.Builder |
canInterruptAndMoveLayoutsBetweenThreads(boolean isEnabled)
Experimental, do not use! If enabled, a layout computation can be interrupted on a bg thread
and resumed on the UI thread if it's needed immediately.
|
RecyclerBinder.Builder |
canMeasure(boolean canMeasure)
Only for horizontally scrolling layouts! If true, the height of the RecyclerView is not known
when it's measured; the first item is measured and its height will determine the height of
the RecyclerView.
|
RecyclerBinder.Builder |
componentsConfiguration(ComponentsConfiguration componentsConfiguration) |
RecyclerBinder.Builder |
componentTreeHolderFactory(com.facebook.litho.widget.RecyclerBinder.ComponentTreeHolderFactory componentTreeHolderFactory) |
RecyclerBinder.Builder |
componentWarmer(ComponentWarmer componentWarmer) |
RecyclerBinder.Builder |
enableCustomViewType(int componentViewType)
Enable setting custom viewTypes on
ViewRenderInfo s. |
RecyclerBinder.Builder |
enableStableIds(boolean enableStableIds)
If set, the RecyclerView adapter will have stableId support turned on.
|
RecyclerBinder.Builder |
errorEventHandler(ErrorEventHandler errorEventHandler) |
RecyclerBinder.Builder |
estimatedViewportCount(int estimatedViewportCount)
This is used in very specific cases on critical performance paths where measuring the first
item cannot be relied on to estimate the viewport count.
|
RecyclerBinder.Builder |
hasDynamicItemHeight(boolean hasDynamicItemHeight)
Do not enable this.
|
RecyclerBinder.Builder |
hscrollAsyncMode(boolean hscrollAsyncMode)
Experimental.
|
RecyclerBinder.Builder |
incrementalMount(boolean incrementalMount)
Don't use this.
|
RecyclerBinder.Builder |
invalidStateLogParamsList(java.util.List<ComponentLogParams> logParamsList)
Provide a list of
ComponentLogParams that will be used to log invalid states in the
LithoView, such as height being 0 while non-0 value was expected. |
RecyclerBinder.Builder |
isCircular(boolean isCircular)
Whether the underlying RecyclerBinder will have a circular behaviour.
|
RecyclerBinder.Builder |
isLayoutDiffingEnabled(boolean isEnabled) |
RecyclerBinder.Builder |
isReconciliationEnabled(boolean isEnabled) |
RecyclerBinder.Builder |
isSubAdapter(boolean isSubAdapter)
Note: this is an advanced usage of RecyclerBinder that requires much more manual hand-holding
of the RecyclerBinder than normal usage.
|
RecyclerBinder.Builder |
layoutHandlerFactory(LayoutHandlerFactory layoutHandlerFactory) |
RecyclerBinder.Builder |
layoutInfo(LayoutInfo layoutInfo) |
RecyclerBinder.Builder |
lithoLifecycleProvider(LithoLifecycleProvider lithoLifecycleProvider) |
RecyclerBinder.Builder |
lithoViewFactory(LithoViewFactory lithoViewFactory) |
RecyclerBinder.Builder |
preallocateMountContentHandler(RunnableHandler preallocateMountContentHandler) |
RecyclerBinder.Builder |
rangeRatio(float rangeRatio) |
RecyclerBinder.Builder |
recyclerRangeTraverser(RecyclerRangeTraverser traverser)
Set a custom range traverser
|
RecyclerBinder.Builder |
recyclerViewItemPrefetch(boolean recyclerViewItemPrefetch)
Set whether item prefetch should be enabled on the underlying RecyclerView.LayoutManager.
|
RecyclerBinder.Builder |
setAdapterDelegate(RecyclerBinderAdapterDelegate delegate)
Set a delegation to customize the adapter behaviour.
|
RecyclerBinder.Builder |
setItemViewCacheSize(int size)
Set the number of offscreen views to retain before adding them to the potentially shared
recycled view pool.
|
RecyclerBinder.Builder |
shouldPreallocatePerMountSpec(boolean shouldPreallocatePerMountSpec) |
RecyclerBinder.Builder |
startupLogger(LithoStartupLogger logger) |
RecyclerBinder.Builder |
stickyHeaderControllerFactory(StickyHeaderControllerFactory stickyHeaderControllerFactory)
Sets a factory to be used to create a custom controller for sticky section headers
|
RecyclerBinder.Builder |
threadPoolConfig(LayoutThreadPoolConfiguration config) |
RecyclerBinder.Builder |
wrapContent(boolean wrapContent)
If true, the underlying RecyclerBinder will measure the parent height by the height of
children if the orientation is vertical, or measure the parent width by the width of children
if the orientation is horizontal.
|
public static final float DEFAULT_RANGE_RATIO
public RecyclerBinder.Builder rangeRatio(float rangeRatio)
rangeRatio
- specifies how big a range this binder should try to compute. The range is
computed as number of items in the viewport (when the binder is measured) multiplied by
the range ratio. The ratio is to be intended in both directions. For example a ratio of 1
means that if there are currently N components on screen, the binder should try to
compute the layout for the N components before the first component on screen and for the
N components after the last component on screen. If not set, defaults to 4f.public RecyclerBinder.Builder acquireStateHandlerOnRelease(boolean acquireStateHandlerOnRelease)
public RecyclerBinder.Builder layoutInfo(LayoutInfo layoutInfo)
layoutInfo
- an implementation of LayoutInfo
that will expose information about
the LayoutManager
this RecyclerBinder will use. If not set, it will default to a
vertical list.public RecyclerBinder.Builder componentsConfiguration(ComponentsConfiguration componentsConfiguration)
public RecyclerBinder.Builder layoutHandlerFactory(LayoutHandlerFactory layoutHandlerFactory)
layoutHandlerFactory
- the RecyclerBinder will use this layoutHandlerFactory when
creating ComponentTree
s in order to specify on which thread layout calculation
should happen.public RecyclerBinder.Builder lithoViewFactory(LithoViewFactory lithoViewFactory)
public RecyclerBinder.Builder isCircular(boolean isCircular)
public RecyclerBinder.Builder wrapContent(boolean wrapContent)
public RecyclerBinder.Builder componentTreeHolderFactory(com.facebook.litho.widget.RecyclerBinder.ComponentTreeHolderFactory componentTreeHolderFactory)
componentTreeHolderFactory
- Factory to acquire a new ComponentTreeHolder. Defaults to
RecyclerBinder.DEFAULT_COMPONENT_TREE_HOLDER_FACTORY
.public RecyclerBinder.Builder preallocateMountContentHandler(RunnableHandler preallocateMountContentHandler)
public RecyclerBinder.Builder shouldPreallocatePerMountSpec(boolean shouldPreallocatePerMountSpec)
public RecyclerBinder.Builder recyclerViewItemPrefetch(boolean recyclerViewItemPrefetch)
ItemPrefetching feature of RecyclerView clashes with RecyclerBinder's compute range optimization and in certain scenarios (like sticky header) it might reset ComponentTree of LithoView while it is still on screen making it render blank or zero height.
public RecyclerBinder.Builder setItemViewCacheSize(int size)
The offscreen view cache stays aware of changes in the attached adapter, allowing a LayoutManager to reuse those views unmodified without needing to return to the adapter to rebind them.
size
- Number of views to cache offscreen before returning them to the general recycled
view poolpublic RecyclerBinder.Builder hasDynamicItemHeight(boolean hasDynamicItemHeight)
Whether the items of this RecyclerBinder can change height after the initial measure. Only applicable to horizontally scrolling RecyclerBinders. If true, the children of this h-scroll are all measured with unspecified height. When the ComponentTree of a child is remeasured, this will cause the RecyclerBinder to remeasure in case the height of the child changed and the RecyclerView needs to have a different height to account for it. This only supports changing the height of the item that triggered the remeasuring, not the height of all items in the h-scroll.
public RecyclerBinder.Builder enableCustomViewType(int componentViewType)
ViewRenderInfo
s.
After this is set, all ViewRenderInfo
s must be built with a custom viewType
through ViewRenderInfo.Builder.customViewType(int)
, otherwise exception will be
thrown.
componentViewType
- the viewType to be used for Component types, provided through ComponentRenderInfo
. Set this to a value that won't conflict with your custom viewTypes.public RecyclerBinder.Builder enableStableIds(boolean enableStableIds)
public RecyclerBinder.Builder invalidStateLogParamsList(java.util.List<ComponentLogParams> logParamsList)
ComponentLogParams
that will be used to log invalid states in the
LithoView, such as height being 0 while non-0 value was expected.public RecyclerBinder.Builder threadPoolConfig(LayoutThreadPoolConfiguration config)
config
- RecyclerBinder will use this LayoutThreadPoolConfiguration
to create
ThreadPoolLayoutHandler
which will be used to calculate layout in pool of
threads. However, this will create a new separate thread pool which might negatively
affect the app's performance.
Note: if layoutHandlerFactory(LayoutHandlerFactory)
is provided, the handler
created by the factory will be used instead of the one that would have been created by
this config.
public RecyclerBinder.Builder recyclerRangeTraverser(RecyclerRangeTraverser traverser)
public RecyclerBinder.Builder setAdapterDelegate(RecyclerBinderAdapterDelegate delegate)
public RecyclerBinder.Builder estimatedViewportCount(int estimatedViewportCount)
public RecyclerBinder.Builder canMeasure(boolean canMeasure)
public RecyclerBinder.Builder hscrollAsyncMode(boolean hscrollAsyncMode)
public RecyclerBinder.Builder incrementalMount(boolean incrementalMount)
public RecyclerBinder.Builder stickyHeaderControllerFactory(StickyHeaderControllerFactory stickyHeaderControllerFactory)
public RecyclerBinder.Builder canInterruptAndMoveLayoutsBetweenThreads(boolean isEnabled)
public RecyclerBinder.Builder isSubAdapter(boolean isSubAdapter)
In sub adapter mode, the RecyclerBinder doesn't control the entire RecyclerView, but instead just a part of it. This means that the RecyclerBinder can't mount to a RecyclerView and set its adapter, and it won't set a scroll listener on the RecyclerView.
Instead, the internal adapter will need to be used/observed and plugged into some sort of multi-adapter that can multiplex the RecyclerView's requests between the different sub adapters.
Additionally, since the RecyclerBinder will never mount to a RecyclerView, the owner of
this RecyclerBinder must manually dispatch RecyclerBinder.updateSubAdapterVisibleRange(int, int)
and RecyclerBinder.updateSubAdapterWorkingRange(int, int, int, int)
events if this RecyclerBinder can contains more than a screens
worth of content.
public RecyclerBinder.Builder isReconciliationEnabled(boolean isEnabled)
public RecyclerBinder.Builder isLayoutDiffingEnabled(boolean isEnabled)
public RecyclerBinder.Builder componentWarmer(ComponentWarmer componentWarmer)
public RecyclerBinder.Builder startupLogger(LithoStartupLogger logger)
public RecyclerBinder.Builder asyncInsertLayoutHandler(RunnableHandler handler)
public RecyclerBinder.Builder errorEventHandler(ErrorEventHandler errorEventHandler)
public RecyclerBinder.Builder lithoLifecycleProvider(LithoLifecycleProvider lithoLifecycleProvider)
public RecyclerBinder build(ComponentContext c)
c
- The ComponentContext
the RecyclerBinder will use.