public abstract class ExpandableViewHolder extends FlexibleViewHolder
This class extends FlexibleViewHolder, which means it will benefit of all
implemented methods the super class holds.
mActionState, mAdapter| Constructor and Description |
|---|
ExpandableViewHolder(android.view.View view,
FlexibleAdapter adapter)
Default constructor.
|
ExpandableViewHolder(android.view.View view,
FlexibleAdapter adapter,
boolean stickyHeader)
Constructor to configure the sticky behaviour of a view.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
collapseView(int position)
Triggers collapse of this itemView.
|
protected void |
expandView(int position)
Triggers expansion of this itemView.
|
android.view.View |
getContentView()
In case this ViewHolder represents a Header Item, this method returns the contentView of the
FrameLayout, otherwise it returns the basic itemView.
|
int |
getFlexibleAdapterPosition()
Overcomes the situation of returning an unknown position (-1) of ViewHolders created out of
the LayoutManager (ex.
|
protected boolean |
isViewCollapsibleOnClick()
Allows to collapse child views of this ItemView when
View.OnClickListener
event occurs on the entire view. |
protected boolean |
isViewCollapsibleOnLongClick()
Allows to collapse child views of this ItemView when
View.OnLongClickListener
event occurs on the entire view. |
protected boolean |
isViewExpandableOnClick()
Allows to expand or collapse child views of this itemView when
View.OnClickListener
event occurs on the entire view. |
void |
onActionStateChanged(int position,
int actionState)
Here we handle the event of when the
ItemTouchHelper first registers an item
as being moved or swiped. |
void |
onClick(android.view.View view)
Called when user taps once on the ItemView.
|
boolean |
onLongClick(android.view.View view)
Called when user long taps on this itemView.
|
void |
setBackupPosition(int backupPosition)
Restore the Adapter position if the original Adapter position is unknown.
|
protected boolean |
shouldNotifyParentOnClick()
Allows to notify change and rebound this itemView on expanding and collapsing events,
in order to update the content (so, user can decide to display the current expanding status).
|
protected void |
toggleExpansion()
Expands or Collapses based on the current state AND on the configuration of the methods
isViewExpandableOnClick() and isViewCollapsibleOnClick(). |
getActivationElevation, getFrontView, getRearLeftView, getRearRightView, isDraggable, isSwipeable, onItemReleased, onTouch, scrollAnimators, setDragHandleView, setFullSpan, shouldActivateViewWhileSwiping, shouldAddSelectionInActionMode, toggleActivationpublic ExpandableViewHolder(android.view.View view,
FlexibleAdapter adapter)
view - The View being hosted in this ViewHolderadapter - Adapter instance of type FlexibleAdapterpublic ExpandableViewHolder(android.view.View view,
FlexibleAdapter adapter,
boolean stickyHeader)
Note: StickyHeader works only if the item has been declared of type
IHeader.
view - The View being hosted in this ViewHolderadapter - Adapter instance of type FlexibleAdapterstickyHeader - true if the View can be a Sticky Header, false otherwiseprotected boolean isViewExpandableOnClick()
View.OnClickListener
event occurs on the entire view.
This method returns always true; Extend with "return false" to Not expand or collapse this ItemView onClick events.
protected boolean isViewCollapsibleOnClick()
View.OnClickListener
event occurs on the entire view.
This method returns always true; Extend with "return false" to Not collapse this ItemView onClick events.
protected boolean isViewCollapsibleOnLongClick()
View.OnLongClickListener
event occurs on the entire view.
This method returns always true; Extend with "return false" to Not collapse this ItemView onLongClick events.
protected boolean shouldNotifyParentOnClick()
This method returns always false; Override with "return true" to trigger the
notification.
expandView(int),
collapseView(int)protected void toggleExpansion()
isViewExpandableOnClick() and isViewCollapsibleOnClick().shouldNotifyParentOnClick(),
isViewExpandableOnClick(),
isViewCollapsibleOnClick(),
expandView(int),
collapseView(int)protected void expandView(int position)
If shouldNotifyParentOnClick() returns true, this view is rebound
with payload Payload.EXPANDED.
shouldNotifyParentOnClick()protected void collapseView(int position)
If shouldNotifyParentOnClick() returns true, this view is rebound
with payload Payload.COLLAPSED.
shouldNotifyParentOnClick()public void onClick(android.view.View view)
Note: In Expandable version, it tries to expand, but before,
it checks if the view isViewExpandableOnClick().
onClick in interface android.view.View.OnClickListeneronClick in class FlexibleViewHolderview - the view that receives the eventFlexibleViewHolder.toggleActivation()public boolean onLongClick(android.view.View view)
Note: In Expandable version, it tries to collapse, but before,
it checks if the view isViewCollapsibleOnLongClick().
onLongClick in interface android.view.View.OnLongClickListeneronLongClick in class FlexibleViewHolderview - the view that receives the eventFlexibleViewHolder.toggleActivation()public void onActionStateChanged(int position,
int actionState)
ItemTouchHelper first registers an item
as being moved or swiped.
In this implementation, View activation is automatically handled if dragged: The Item will be added to the selection list if not selected yet and mode MULTI is activated.
Note: In the Expandable version, expanded items are forced to collapse.
onActionStateChanged in interface ItemTouchHelperCallback.ViewHolderCallbackonActionStateChanged in class FlexibleViewHolderposition - the position of the item touchedactionState - one of ItemTouchHelper#ACTION_STATE_SWIPE or
ItemTouchHelper#ACTION_STATE_DRAG.FlexibleViewHolder.shouldActivateViewWhileSwiping(),
FlexibleViewHolder.shouldAddSelectionInActionMode()public final android.view.View getContentView()
public final int getFlexibleAdapterPosition()
NOTE: Always call this method, instead of getAdapterPosition(), in case
of StickyHeaders use case.
#getAdapterPosition() OR the backup position
preset and known, if the previous result was RecyclerView#NO_POSITION.setBackupPosition(int)public final void setBackupPosition(int backupPosition)
Called by StickyHeaderHelper to support the clickListeners events.
backupPosition - the known position of this ViewHolder