public abstract class Decorator
extends java.lang.Object
Decorations will be drawn in the order by which they were added to the ItemBinder
or
Section
.
Also ItemBinder
's decoration will be applied only after applying the Section
's
decoration
Constructor and Description |
---|
Decorator(MultiViewAdapter adapter)
Constructor which initialized the Decorator with the adapter object.
|
Modifier and Type | Method and Description |
---|---|
void |
addToRect(android.graphics.Rect outRect,
int left,
int top,
int right,
int bottom)
Utility method to add the coordinates to the existing values to the Rect class
|
abstract void |
getItemOffsets(android.graphics.Rect outRect,
android.view.View view,
RecyclerView parent,
RecyclerView.State state,
int adapterPosition)
Retrieve item offsets for the given position.
|
int |
getPositionType(int adapterPosition,
RecyclerView parent)
Returns the position type of the item for given adapter position.
|
SectionPositionType |
getSectionPositionType(int adapterPosition)
Returns the
SectionPositionType for the given adapter position. |
boolean |
isFirst(int positionType)
Returns whether the item is first element in the
LinearLayoutManager . |
boolean |
isItemOnBottomEdge(int positionType)
Returns whether the item is on the bottom edge of the
RecyclerView . |
boolean |
isItemOnLeftEdge(int positionType)
Returns whether the item is on the left edge of the
RecyclerView . |
boolean |
isItemOnRightEdge(int positionType)
Returns whether the item is on the right edge of the
RecyclerView . |
boolean |
isItemOnTopEdge(int positionType)
Returns whether the item is on the top edge of the
RecyclerView . |
boolean |
isLast(int positionType)
Returns whether the item is last element in the
LinearLayoutManager . |
void |
onDraw(android.graphics.Canvas canvas,
RecyclerView parent,
RecyclerView.State state,
android.view.View child,
int adapterPosition)
Draw any appropriate decorations into the Canvas supplied to the RecyclerView.
|
void |
onDrawOver(android.graphics.Canvas canvas,
RecyclerView parent,
RecyclerView.State state,
android.view.View child,
int adapterPosition)
Draw any appropriate decorations into the Canvas supplied to the RecyclerView.
|
public Decorator(MultiViewAdapter adapter)
adapter
- MultiViewAaapter that is attached with this decorator.public void addToRect(android.graphics.Rect outRect, int left, int top, int right, int bottom)
outRect
- Rect object for which the values are updatedleft
- The X coordinate of the left side of the rectangletop
- The Y coordinate of the top of the rectangleright
- The X coordinate of the right side of the rectanglebottom
- The Y coordinate of the bottom of the rectanglepublic int getPositionType(int adapterPosition, RecyclerView parent)
adapterPosition
- Item position inside the adapter for which position type is calculatedparent
- Parent recyclerviewPositionType
public SectionPositionType getSectionPositionType(int adapterPosition)
SectionPositionType
for the given adapter position.adapterPosition
- Position of the item inside the recyclerviewpublic boolean isFirst(int positionType)
Returns whether the item is first element in the LinearLayoutManager
. Avoid using this
method on GridLayoutManager
PositionType
public boolean isItemOnBottomEdge(int positionType)
Returns whether the item is on the bottom edge of the RecyclerView
.
PositionType
public boolean isItemOnLeftEdge(int positionType)
Returns whether the item is on the left edge of the RecyclerView
.
PositionType
public boolean isItemOnRightEdge(int positionType)
Returns whether the item is on the right edge of the RecyclerView
.
PositionType
public boolean isItemOnTopEdge(int positionType)
Returns whether the item is on the top edge of the RecyclerView
.
PositionType
public boolean isLast(int positionType)
Returns whether the item is last element in the LinearLayoutManager
. Avoid using this
method on GridLayoutManager
PositionType
public void onDraw(android.graphics.Canvas canvas, RecyclerView parent, RecyclerView.State state, android.view.View child, int adapterPosition)
canvas
- The canvas to draw intoparent
- The recyclerView this decoration is drawing intostate
- The current state of RecyclerViewchild
- The child for which item decoration is being drawnadapterPosition
- The item's position inside the recyclerviewSectionPositionType
,
PositionType
public void onDrawOver(android.graphics.Canvas canvas, RecyclerView parent, RecyclerView.State state, android.view.View child, int adapterPosition)
canvas
- The canvas to draw intoparent
- The recyclerView this decoration is drawing intostate
- The current state of RecyclerViewchild
- The child for which item decoration is being drawnadapterPosition
- The item's position inside the recyclerviewSectionPositionType
,
PositionType
public abstract void getItemOffsets(android.graphics.Rect outRect, android.view.View view, RecyclerView parent, RecyclerView.State state, int adapterPosition)
Each field of rectUtil
specifies the number of pixels that the item view should be
inset by, similar to padding or margin.
The default implementation sets the bounds of rectUtil to 0 and returns.
If this ItemDecoration does affect the positioning of item views, it should set
any of four fields of rectUtil
(left, top, right, bottom).
outRect
- Rect to receive the output.view
- The child view to decorateparent
- RecyclerView this ItemDecoration is decoratingstate
- The current state of RecyclerView.adapterPosition
- The item's position inside the recyclerviewSectionPositionType
,
PositionType