public class StaggeredGridLayoutInfo extends java.lang.Object implements LayoutInfo
LayoutInfo
to implement staggered grids with a StaggeredGridLayoutManager
.LayoutInfo.RenderInfoCollection
ViewportInfo.State, ViewportInfo.ViewportChanged
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
OVERRIDE_SIZE |
Constructor and Description |
---|
StaggeredGridLayoutInfo(int spanCount,
int orientation,
boolean reverseLayout,
int gapStrategy) |
StaggeredGridLayoutInfo(int spanCount,
int orientation,
boolean reverseLayout,
int gapStrategy,
boolean eagerlyClearsSpanAssignmentsOnUpdates,
boolean invalidatesItemDecorationsOnUpdates) |
Modifier and Type | Method and Description |
---|---|
int |
approximateRangeSize(int firstMeasuredItemWidth,
int firstMeasuredItemHeight,
int recyclerMeasuredWidth,
int recyclerMeasuredHeight)
This is called when the
RecyclerBinder needs to calculate a range size. |
int |
computeWrappedHeight(int maxHeight,
java.util.List<ComponentTreeHolder> componentTreeHolders) |
com.facebook.litho.widget.StaggeredGridLayoutInfo.ViewportFiller |
createViewportFiller(int measuredWidth,
int measuredHeight) |
int |
findFirstFullyVisibleItemPosition() |
int |
findFirstVisibleItemPosition() |
int |
findLastFullyVisibleItemPosition() |
int |
findLastVisibleItemPosition() |
int |
getChildHeightSpec(int heightSpec,
RenderInfo renderInfo) |
int |
getChildWidthSpec(int widthSpec,
RenderInfo renderInfo) |
int |
getItemCount() |
RecyclerView.LayoutManager |
getLayoutManager() |
int |
getScrollDirection()
This is the main scrolling direction that the
LayoutManager passed to this binder will
use. |
void |
scrollToPositionWithOffset(int position,
int offset)
RecyclerBinder delegates scrolling responsibilities to the LayoutInfo, as the varied
LayoutManagers wrapped by a LayoutInfo lack a common scrolling interface.
|
void |
setRenderInfoCollection(LayoutInfo.RenderInfoCollection renderInfoCollection) |
public static final java.lang.String OVERRIDE_SIZE
public StaggeredGridLayoutInfo(int spanCount, int orientation, boolean reverseLayout, int gapStrategy)
public StaggeredGridLayoutInfo(int spanCount, int orientation, boolean reverseLayout, int gapStrategy, boolean eagerlyClearsSpanAssignmentsOnUpdates, boolean invalidatesItemDecorationsOnUpdates)
public int getScrollDirection()
LayoutInfo
LayoutManager
passed to this binder will
use.getScrollDirection
in interface LayoutInfo
OrientationHelper#HORIZONTAL
or OrientationHelper#VERTICAL
.public RecyclerView.LayoutManager getLayoutManager()
getLayoutManager
in interface LayoutInfo
LayoutManager
to be used with the RecyclerView
.public void setRenderInfoCollection(LayoutInfo.RenderInfoCollection renderInfoCollection)
setRenderInfoCollection
in interface LayoutInfo
public void scrollToPositionWithOffset(int position, int offset)
LayoutInfo
scrollToPositionWithOffset
in interface LayoutInfo
position
- Index of the item in the adapteroffset
- Additional adjustment to control the precise position the scroll moves to.public int approximateRangeSize(int firstMeasuredItemWidth, int firstMeasuredItemHeight, int recyclerMeasuredWidth, int recyclerMeasuredHeight)
LayoutInfo
RecyclerBinder
needs to calculate a range size. The returned
value should be an approximate range size based on the size of the first measured item.approximateRangeSize
in interface LayoutInfo
firstMeasuredItemWidth
- The width of the first item measured while computing the range.firstMeasuredItemHeight
- The height of the first item measured while computing the range.recyclerMeasuredWidth
- The measured width of the RecyclerView. If the RecyclerView
scrolls vertically this might be not significant.recyclerMeasuredHeight
- The measured height of the RecyclerView. If the RecyclerView
scrolls horizontally this might be not significant.public int getChildWidthSpec(int widthSpec, RenderInfo renderInfo)
getChildWidthSpec
in interface LayoutInfo
widthSpec
- the widthSpec used to measure the parent RecyclerSpec
.renderInfo
- retrieve SpanSize of the component if it is a GridLayoutInfo
public int getChildHeightSpec(int heightSpec, RenderInfo renderInfo)
getChildHeightSpec
in interface LayoutInfo
heightSpec
- the heightSpec used to measure the parent RecyclerSpec
.renderInfo
- retrieve SpanSize of the component if it is a GridLayoutInfo
public com.facebook.litho.widget.StaggeredGridLayoutInfo.ViewportFiller createViewportFiller(int measuredWidth, int measuredHeight)
createViewportFiller
in interface LayoutInfo
measuredWidth
- the width of the RecyclerViewmeasuredHeight
- the height of the RecyclerViewLayoutInfo.ViewportFiller
to fill the RecyclerView viewport with views, or null to not
pre-fill the RecyclerView.public int findFirstVisibleItemPosition()
findFirstVisibleItemPosition
in interface ViewportInfo
public int findLastVisibleItemPosition()
findLastVisibleItemPosition
in interface ViewportInfo
public int findFirstFullyVisibleItemPosition()
findFirstFullyVisibleItemPosition
in interface ViewportInfo
public int findLastFullyVisibleItemPosition()
findLastFullyVisibleItemPosition
in interface ViewportInfo
public int getItemCount()
getItemCount
in interface ViewportInfo
public int computeWrappedHeight(int maxHeight, java.util.List<ComponentTreeHolder> componentTreeHolders)
computeWrappedHeight
in interface LayoutInfo
maxHeight
- the max height of the parent RecyclerSpec
.componentTreeHolders
- the list of ComponentTreeHolder
in this RecyclerBinder
.RecyclerBinder
.