RecyclerBinder
This binder class is used to asynchronously layout Components given a list of Component and attaching them to a Recycler.
Types
Defines when a batch should be committed: - IMMEDIATE: Commit batches to the RecyclerView as soon as possible. - LAYOUT_BEFORE_INSERT: Commit batches to the RecyclerView only after the layouts for all insert operations have been completed.
Strategies for recycling layouts of items in binder
Properties
To avoid creating a new runnable for each ComponentTreeHolder, we maintain a task queue to consume them in order.
Return true if wrap content is enabled for the cross axis, false otherwise.
Return true if wrap content is enabled for the main axis, false otherwise.
Functions
See RecyclerBinder#appendItem(RenderInfo).
Inserts a new item at tail. The RecyclerView gets notified immediately about the new item being inserted. If the item's position falls within the currently visible range, the layout is immediately computed on the] UiThread. The RenderInfo contains the component that will be inserted in the Binder and extra info like isSticky or spanCount.
Removes all items in this binder async.
Returns the ComponentTree for the item at index position. TODO 16212132 remove getComponentAt from binder
Gets the number of items currently in the adapter attached to this binder (i.e. the number of items the underlying RecyclerView knows about).
See RecyclerBinder#insertItemAt(int, RenderInfo).
Inserts a new item at position. The RecyclerView gets notified immediately about the new item being inserted. If the item's position falls within the currently visible range, the layout is immediately computed on the] UiThread. The RenderInfo contains the component that will be inserted in the Binder and extra info like isSticky or spanCount.
Inserts an item at position. The RecyclerView will only be notified of the item being inserted after a layout calculation has been completed for the new Component.
Inserts the new items starting from position. The RecyclerView gets notified immediately about the new item being inserted. The RenderInfo contains the component that will be inserted in the Binder and extra info like isSticky or spanCount.
Inserts the new items starting from position. The RecyclerView will only be notified of the items being inserted after a layout calculation has been completed for the new Components. There is not a guarantee that the RecyclerView will be notified about all the items in the range at the same time.
A component mounting a RecyclerView can use this method to determine its size. A Recycler that scrolls horizontally will leave the width unconstrained and will measure its children with a sizeSpec for the height matching the heightSpec passed to this method.
Call from the owning Component's onMount. This is where the adapter is assigned to the RecyclerView.
Moves an item from fromPosition to toPosition. If there are other pending operations on this binder this will only be executed when all the operations have been completed (to ensure index consistency).
Called after all the change set operations (inserts, removes, etc.) in a batch have completed.
Called after all the change set operations (inserts, removes, etc.) in a batch have completed. Async variant, may be called off the main thread.
Removes an item from index position.
Removes an item from position. If there are other pending operations on this binder this will only be executed when all the operations have been completed (to ensure index consistency).Return true if the item was removed, false if the item was not removed.
Removes count items starting from position.
Removes count items starting from position. If there are other pending operations on this binder this will only be executed when all the operations have been completed (to ensure index consistency). Return true if the range was removed, false if the range was not removed.
Replaces all items in the RecyclerBinder with the provided RenderInfos.
This should be called when the owner Component's onBoundsDefined is called. It will inform the binder of the final measured size. The binder might decide to re-compute its children layouts if the measures provided here are not compatible with the ones receive in onMeasure.
Bind a ViewportInfo.ViewportChanged listener to this Binder. The listener will be notified of Viewport changes.
Call from the owning Component's onUnmount. This is where the adapter is removed from the RecyclerView.
See RecyclerBinder#updateItemAt(int, Component).
Updates the item at position. The RecyclerView gets notified immediately about the item being updated. If the item's position falls within the currently visible range, the layout is immediately computed on the UiThread.
Update the item at index position. The RecyclerView will only be notified of the item being updated after a layout calculation has been completed for the new Component.
Updates the range of items starting at position. The RecyclerView gets notified immediately about the item being updated.
Update the items starting from the given index position. The RecyclerView will only be notified of the item being updated after a layout calculation has been completed for the new Component.
Updates the visible range when in sub adapter mode. Do not call this otherwise. This method exists because in sub adapter mode, the RecyclerBinder is never mounted to a RecyclerView and needs outside signals from the multiplexing adapter to determine which of its indices are visible.
Updates the working range when in sub adapter mode. Do not call this otherwise. This method exists because in sub adapter mode, the RecyclerBinder is never mounted to a RecyclerView and needs outside signals from the multiplexing adapter to determine which of its indices are visible.