public class ParentViewHolder<P extends Parent<C>,C>
extends RecyclerView.ViewHolder
implements android.view.View.OnClickListener
Parent
Keeps track of expanded state and holds callbacks which can be used to
trigger expansion-based events.| Constructor and Description |
|---|
ParentViewHolder(android.view.View itemView)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
collapseView()
Triggers collapse of the parent.
|
protected void |
expandView()
Triggers expansion of the parent.
|
P |
getParent() |
int |
getParentAdapterPosition()
Returns the adapter position of the Parent associated with this ParentViewHolder
|
boolean |
isExpanded()
Returns expanded state for the
Parent
corresponding to this ParentViewHolder. |
void |
onClick(android.view.View v)
View.OnClickListener to listen for click events on
the entire parent View. |
void |
onExpansionToggled(boolean expanded)
Callback triggered when expansion state is changed, but not during
initialization.
|
void |
setExpanded(boolean expanded)
Setter method for expanded state, used for initialization of expanded state.
|
void |
setMainItemClickToExpand()
Sets a
View.OnClickListener on the entire parent
view to trigger expansion. |
boolean |
shouldItemViewClickToggleExpansion()
Used to determine whether a click in the entire parent
View
should trigger row expansion. |
@UiThread
public ParentViewHolder(@NonNull
android.view.View itemView)
itemView - The View being hosted in this ViewHolder@UiThread public P getParent()
@UiThread public int getParentAdapterPosition()
@UiThread public void setMainItemClickToExpand()
View.OnClickListener on the entire parent
view to trigger expansion.@UiThread public boolean isExpanded()
Parent
corresponding to this ParentViewHolder.@UiThread public void setExpanded(boolean expanded)
onExpansionToggled(boolean)expanded - true if expanded, false if not@UiThread public void onExpansionToggled(boolean expanded)
Useful for implementing animations on expansion.
expanded - true if view is expanded before expansion is toggled,
false if not@UiThread public void onClick(android.view.View v)
View.OnClickListener to listen for click events on
the entire parent View.
Only registered if shouldItemViewClickToggleExpansion() is true.
onClick in interface android.view.View.OnClickListenerv - The View that is the trigger for expansion@UiThread public boolean shouldItemViewClickToggleExpansion()
View
should trigger row expansion.
If you return false, you can call expandView() to trigger an
expansion in response to a another event or collapseView() to
trigger a collapse.
View.OnClickListener on the item view@UiThread protected void expandView()
@UiThread protected void collapseView()