@ThreadSafe public class RecyclerBinder extends Object implements Binder<RecyclerView>, LayoutInfo.RenderInfoCollection
Component
and attaching them to a RecyclerSpec
.Modifier and Type | Class and Description |
---|---|
static class |
RecyclerBinder.Builder |
static class |
RecyclerBinder.RecyclerViewLayoutManagerOverrideParams |
ViewportInfo.State, ViewportInfo.ViewportChanged
Modifier and Type | Method and Description |
---|---|
void |
appendItem(Component component)
|
void |
appendItem(RenderInfo renderInfo)
Inserts a new item at tail.
|
void |
bind(RecyclerView view)
Bind this
Binder to a View . |
int |
findFirstFullyVisibleItemPosition() |
int |
findFirstVisibleItemPosition() |
int |
findLastFullyVisibleItemPosition() |
int |
findLastVisibleItemPosition() |
ComponentTree |
getComponentAt(int position)
Returns the
ComponentTree for the item at index position. |
ComponentTree |
getComponentForStickyHeaderAt(int position) |
int |
getItemCount()
Gets the number of items in this binder.
|
RenderInfo |
getRenderInfoAt(int position) |
void |
insertItemAt(int position,
Component component)
|
void |
insertItemAt(int position,
RenderInfo renderInfo)
Inserts a new item at position.
|
void |
insertItemAtAsync(int position,
RenderInfo renderInfo)
Inserts an item at position.
|
void |
insertRangeAt(int position,
List<RenderInfo> renderInfos)
Inserts the new items starting from position.
|
void |
insertRangeAtAsync(int position,
List<RenderInfo> renderInfos)
Inserts the new items starting from position.
|
boolean |
isSticky(int position) |
boolean |
isValidPosition(int position) |
void |
measure(Size outSize,
int widthSpec,
int heightSpec,
EventHandler<ReMeasureEvent> reMeasureEventHandler)
A component mounting a RecyclerView can use this method to determine its size.
|
void |
mount(RecyclerView view)
Call from the owning
Component 's onMount. |
void |
moveItem(int fromPosition,
int toPosition)
Moves an item from fromPosition to toPosition.
|
void |
moveItemAsync(int fromPosition,
int toPosition)
Moves an item from fromPosition to toPostion.
|
void |
removeItemAt(int position)
Removes an item from index position.
|
void |
removeItemAtAsync(int position)
Removes an item from position.
|
void |
removeRangeAt(int position,
int count)
Removes count items starting from position.
|
void |
scrollToPosition(int position) |
void |
scrollToPositionWithOffset(int position,
int offset) |
void |
setSize(int width,
int height)
This should be called when the owner
Component 's onBoundsDefined is called. |
void |
setViewportChangedListener(ViewportInfo.ViewportChanged viewportChangedListener)
Bind a
ViewportInfo.ViewportChanged listener to this Binder . |
void |
unbind(RecyclerView view)
Call this method when the view is unbound.
|
void |
unmount(RecyclerView view)
Call from the owning
Component 's onUnmount. |
void |
updateItemAt(int position,
Component component)
|
void |
updateItemAt(int position,
RenderInfo renderInfo)
Updates the item at position.
|
void |
updateItemAtAsync(int position,
RenderInfo renderInfo)
Update the item at index position.
|
void |
updateRangeAt(int position,
List<RenderInfo> renderInfos)
Updates the range of items starting at position.
|
@UiThread public final void updateItemAtAsync(int position, RenderInfo renderInfo)
RecyclerView
will only be notified of the item
being updated after a layout calculation has been completed for the new Component
.@UiThread public final void insertItemAtAsync(int position, RenderInfo renderInfo)
RecyclerView
will only be notified of the item being
inserted after a layout calculation has been completed for the new Component
.@UiThread public final void insertRangeAtAsync(int position, List<RenderInfo> renderInfos)
RecyclerView
will only be notified of
the items being inserted after a layout calculation has been completed for the new Component
s. There is not a guarantee that the RecyclerView
will be notified about all
the items in the range at the same time.@UiThread public final void moveItemAsync(int fromPosition, int toPosition)
@UiThread public final void removeItemAtAsync(int position)
@UiThread public final void appendItem(RenderInfo renderInfo)
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.@UiThread public final void insertItemAt(int position, RenderInfo renderInfo)
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.@UiThread public final void insertRangeAt(int position, List<RenderInfo> renderInfos)
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.@UiThread public final void updateItemAt(int position, RenderInfo renderInfo)
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.@UiThread public final void updateRangeAt(int position, List<RenderInfo> renderInfos)
RecyclerView
gets notified
immediately about the item being updated.@UiThread public final void moveItem(int fromPosition, int toPosition)
@UiThread public final void removeItemAt(int position)
@UiThread public final void removeRangeAt(int position, int count)
@Nullable public final ComponentTree getComponentAt(int position)
ComponentTree
for the item at index position. TODO 16212132 remove
getComponentAt from bindergetComponentAt
in interface Binder<RecyclerView>
public final ComponentTree getComponentForStickyHeaderAt(int position)
public final RenderInfo getRenderInfoAt(int position)
getRenderInfoAt
in interface LayoutInfo.RenderInfoCollection
public void bind(RecyclerView view)
Binder
public void unbind(RecyclerView view)
Binder
public void measure(Size outSize, int widthSpec, int heightSpec, EventHandler<ReMeasureEvent> reMeasureEventHandler)
measure
in interface Binder<RecyclerView>
outSize
- will be populated with the measured dimensions for this Binder.widthSpec
- the widthSpec to be used to measure the RecyclerView.heightSpec
- the heightSpec to be used to measure the RecyclerView.reMeasureEventHandler
- the EventHandler to invoke in order to trigger a re-measure.public int getItemCount()
public void setSize(int width, int height)
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.@UiThread public void mount(RecyclerView view)
Component
's onMount. This is where the adapter is assigned to the
RecyclerView
.@UiThread public void unmount(RecyclerView view)
Component
's onUnmount. This is where the adapter is removed from
the RecyclerView
.@UiThread public void scrollToPosition(int position)
@UiThread public void scrollToPositionWithOffset(int position, int offset)
public int findFirstVisibleItemPosition()
public int findFirstFullyVisibleItemPosition()
public int findLastVisibleItemPosition()
public int findLastFullyVisibleItemPosition()
@UiThread public boolean isSticky(int position)
@UiThread public boolean isValidPosition(int position)
@UiThread public void setViewportChangedListener(@Nullable ViewportInfo.ViewportChanged viewportChangedListener)
Binder
ViewportInfo.ViewportChanged
listener to this Binder
.
The listener will be notified of Viewport changes.setViewportChangedListener
in interface Binder<RecyclerView>