public class

RecyclerViewExpandableItemManager

extends Object
implements ExpandableItemConstants
java.lang.Object
   ↳ com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager

Class Overview

Provides item expansion operation for androidx.recyclerview.widget.RecyclerView

Summary

Nested Classes
interface RecyclerViewExpandableItemManager.OnGroupCollapseListener Used for being notified when a group is collapsed  
interface RecyclerViewExpandableItemManager.OnGroupExpandListener Used for being notified when a group is expanded  
class RecyclerViewExpandableItemManager.SavedState  
Constants
long NO_EXPANDABLE_POSITION Packed position version of NO_POSITION
[Expand]
Inherited Constants
From interface com.h6ah4i.android.widget.advrecyclerview.expandable.ExpandableItemConstants
Public Constructors
RecyclerViewExpandableItemManager(Parcelable savedState)
Constructor.
Public Methods
void attachRecyclerView(RecyclerView rv)

Attaches androidx.recyclerview.widget.RecyclerView instance.

void collapseAll()

Collapse all groups.

boolean collapseGroup(int groupPosition, Object payload)
Collapse a group.
boolean collapseGroup(int groupPosition)
Collapse a group.
Adapter createWrappedAdapter(Adapter adapter)
Create wrapped adapter.
void expandAll()

Expand all groups.

boolean expandGroup(int groupPosition)
Expand a group.
boolean expandGroup(int groupPosition, Object payload)
Expand a group.
int getChildCount(int groupPosition)
Gets the number of children in a specified group.
static long getChildItemId(long rawId)
Gets child item ID from a raw ID.
static int getChildViewType(int rawViewType)
Gets child view type from a raw view type.
int getCollapsedGroupsCount()
Gets the number of collapsed groups.
static long getCombinedChildId(long groupId, long childId)

Gets combined ID for child item.

static long getCombinedGroupId(long groupId)

Gets combined ID for child item.

boolean getDefaultGroupsExpandedState()
Gets default group items expanded state
long getExpandablePosition(int flatPosition)
Converts a flat position (the raw position of an item in the list) to a group and/or child position (represented in a packed position).
int getExpandedGroupsCount()
Gets the number of expanded groups.
int getFlatPosition(long packedPosition)
Converts a group and/or child position to a flat position.
int getGroupCount()
Gets the number of groups.
static long getGroupItemId(long rawId)
Gets group item ID from a raw ID.
static int getGroupViewType(int rawViewType)
Gets group view type from a raw view type.
static int getPackedPositionChild(long packedPosition)
Gets the child position from a packed position.
static long getPackedPositionForChild(int groupPosition, int childPosition)

Returns the packed position representation of a child position.

static long getPackedPositionForGroup(int groupPosition)
Returns the packed position representation of a group's position.
static int getPackedPositionGroup(long packedPosition)
Gets the group position from a packed position.
Parcelable getSavedState()

Gets saved state object in order to restore the internal state.

boolean isAllGroupsCollapsed()
Whether the all groups are expanded.
boolean isAllGroupsExpanded()
Whether the all groups are expanded.
boolean isGroupExpanded(int groupPosition)
Whether the given group is currently expanded.
static boolean isGroupItemId(long rawId)
Checks whether the passed item ID is a group's one.
static boolean isGroupViewType(int rawViewType)
Checks whether the passed view type is a group's one.
boolean isReleased()
Indicates this manager instance has released or not.
void notifyChildItemChanged(int groupPosition, int childPosition, Object payload)

Notify any registered observers that the child item at {groupPosition, childPosition} has changed.

void notifyChildItemChanged(int groupPosition, int childPosition)

Notify any registered observers that the child item at {groupPosition, childPosition} has changed.

void notifyChildItemInserted(int groupPosition, int childPosition)

Notify any registered observers that the group item reflected at groupPosition has been newly inserted.

void notifyChildItemMoved(int fromGroupPosition, int fromChildPosition, int toGroupPosition, int toChildPosition)

Notify any registered observers that the child item reflected at fromGroupPosition, fromChildPosition has been moved to toGroupPosition, toChildPosition.

void notifyChildItemMoved(int groupPosition, int fromChildPosition, int toChildPosition)

Notify any registered observers that the child item reflected at groupPosition, fromChildPosition has been moved to groupPosition, toChildPosition.

void notifyChildItemRangeChanged(int groupPosition, int childPositionStart, int itemCount)

Notify any registered observers that the itemCount child items starting at position {groupPosition, childPosition} have changed.

void notifyChildItemRangeChanged(int groupPosition, int childPositionStart, int itemCount, Object payload)

Notify any registered observers that the itemCount child items starting at position {groupPosition, childPosition} have changed.

void notifyChildItemRangeInserted(int groupPosition, int childPositionStart, int itemCount)

Notify any registered observers that the currently reflected itemCount child items starting at childPositionStart have been newly inserted.

void notifyChildItemRangeRemoved(int groupPosition, int childPositionStart, int itemCount)

Notify any registered observers that the itemCount child items previously located at childPositionStart have been removed from the data set.

void notifyChildItemRemoved(int groupPosition, int childPosition)

Notify any registered observers that the child item previously located at childPosition has been removed from the data set.

void notifyChildrenOfGroupItemChanged(int groupPosition, Object payload)

Notify any registered observers that the children items contained in the group item at groupPosition have changed.

void notifyChildrenOfGroupItemChanged(int groupPosition)

Notify any registered observers that the children items contained in the group item at groupPosition have changed.

void notifyGroupAndChildrenItemsChanged(int groupPosition)

Notify any registered observers that the group and children items at groupPosition have changed.

void notifyGroupAndChildrenItemsChanged(int groupPosition, Object payload)

Notify any registered observers that the group and children items at groupPosition have changed.

void notifyGroupItemChanged(int groupPosition, Object payload)

Notify any registered observers that the group item at groupPosition has changed with an optional payload object.

void notifyGroupItemChanged(int groupPosition)

Notify any registered observers that the group item at groupPosition has changed.

void notifyGroupItemInserted(int groupPosition, boolean expanded)

Notify any registered observers that the group item reflected at groupPosition has been newly inserted.

void notifyGroupItemInserted(int groupPosition)

Notify any registered observers that the group item reflected at groupPosition has been newly inserted.

void notifyGroupItemMoved(int fromGroupPosition, int toGroupPosition)

Notify any registered observers that the group item reflected at fromGroupPosition has been moved to toGroupPosition.

void notifyGroupItemRangeInserted(int groupPositionStart, int itemCount, boolean expanded)

Notify any registered observers that the currently reflected itemCount group items starting at groupPositionStart have been newly inserted and may be expanded.

void notifyGroupItemRangeInserted(int groupPositionStart, int itemCount)

Notify any registered observers that the currently reflected itemCount group items starting at groupPositionStart have been newly inserted.

void notifyGroupItemRangeRemoved(int groupPositionStart, int itemCount)

Notify any registered observers that the itemCount group items previously located at groupPositionStart have been removed from the data set.

void notifyGroupItemRemoved(int groupPosition)

Notify any registered observers that the group item previously located at groupPosition has been removed from the data set.

void release()

Detach the androidx.recyclerview.widget.RecyclerView instance and release internal field references.

void restoreState(Parcelable savedState)
Restore saves state.
void restoreState(Parcelable savedState, boolean callHooks, boolean callListeners)

Restore saves state.

void scrollToGroup(int groupPosition, int childItemHeight)
Scroll to a group.
void scrollToGroup(int groupPosition, int childItemHeight, int topMargin, int bottomMargin, AdapterPath path)
Scroll to a group.
void scrollToGroup(int groupPosition, int childItemHeight, int topMargin, int bottomMargin)
Scroll to a group.
void scrollToGroupWithTotalChildrenHeight(int groupPosition, int totalChildrenHeight, int topMargin, int bottomMargin)
Scroll to a group with specifying total children height.
void scrollToGroupWithTotalChildrenHeight(int groupPosition, int totalChildrenHeight, int topMargin, int bottomMargin, AdapterPath path)
Scroll to a group with specifying total children height.
void setDefaultGroupsExpandedState(boolean expanded)
Sets default group items expanded state
void setOnGroupCollapseListener(RecyclerViewExpandableItemManager.OnGroupCollapseListener listener)
Register a callback to be invoked when an group item has been collapsed.
void setOnGroupExpandListener(RecyclerViewExpandableItemManager.OnGroupExpandListener listener)
Register a callback to be invoked when an group item has been expanded.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final long NO_EXPANDABLE_POSITION

Packed position version of NO_POSITION

Constant Value: -1 (0xffffffffffffffff)

Public Constructors

public RecyclerViewExpandableItemManager (Parcelable savedState)

Constructor.

Parameters
savedState The saved state object which is obtained from the getSavedState() method.

Public Methods

public void attachRecyclerView (RecyclerView rv)

Attaches androidx.recyclerview.widget.RecyclerView instance.

Before calling this method, the target androidx.recyclerview.widget.RecyclerView must set the wrapped adapter instance which is returned by the createWrappedAdapter(androidx.recyclerview.widget.RecyclerView.Adapter) method.

Parameters
rv The androidx.recyclerview.widget.RecyclerView instance

public void collapseAll ()

Collapse all groups.

Note that this method does not invoke the onGroupCollapse(int, boolean, Object) callback.

public boolean collapseGroup (int groupPosition, Object payload)

Collapse a group.

Parameters
groupPosition The group position to be collapsed
payload Optional parameter, use null to identify a "full" update the group item
Returns
  • True if the group was collapsed, false otherwise (If the group was already collapsed, this will return false)

public boolean collapseGroup (int groupPosition)

Collapse a group.

Parameters
groupPosition The group position to be collapsed
Returns
  • True if the group was collapsed, false otherwise (If the group was already collapsed, this will return false)

public Adapter createWrappedAdapter (Adapter adapter)

Create wrapped adapter.

Parameters
adapter The target adapter.
Returns

public void expandAll ()

Expand all groups.

Note that this method does not invoke the onGroupExpand(int, boolean, Object) callback.

public boolean expandGroup (int groupPosition)

Expand a group.

Parameters
groupPosition The group position to be expanded
Returns
  • True if the group was expanded, false otherwise (If the group was already expanded, this will return false)

public boolean expandGroup (int groupPosition, Object payload)

Expand a group.

Parameters
groupPosition The group position to be expanded
payload Optional parameter, use null to identify a "full" update the group item
Returns
  • True if the group was expanded, false otherwise (If the group was already expanded, this will return false)

public int getChildCount (int groupPosition)

Gets the number of children in a specified group.

Parameters
groupPosition the position of the group for which the children count should be returned
Returns
  • the number of children

public static long getChildItemId (long rawId)

Gets child item ID from a raw ID.

Parameters
rawId raw item ID value (return value of getItemId())
Returns
  • Child item ID for the given raw item ID.

public static int getChildViewType (int rawViewType)

Gets child view type from a raw view type.

Parameters
rawViewType raw view type value (return value of getItemViewType())
Returns
  • Child view type for the given raw view type.

public int getCollapsedGroupsCount ()

Gets the number of collapsed groups.

Returns
  • the number of collapsed groups

public static long getCombinedChildId (long groupId, long childId)

Gets combined ID for child item.

bit 0-27: Lower 28 bits of the childId bit 28-55: Lower 28 bits of the groupId bit 56-61: reserved

Parameters
groupId The ID of the group that contains the child.
childId The ID of the child.
Returns
  • The unique ID of the child across all groups and children in the list

public static long getCombinedGroupId (long groupId)

Gets combined ID for child item.

bit 0-27: all bits are set to 1 bit 28-55: Lower 28 bits of the groupId bit 56-61: reserved

Parameters
groupId The ID of the group that contains the child.
Returns
  • The unique ID of the child across all groups and children in the list

public boolean getDefaultGroupsExpandedState ()

Gets default group items expanded state

Returns
  • True if groups are expanded by default, otherwise false.

public long getExpandablePosition (int flatPosition)

Converts a flat position (the raw position of an item in the list) to a group and/or child position (represented in a packed position). Use getPackedPositionChild(long), getPackedPositionGroup(long) to unpack.

Parameters
flatPosition The flat position to be converted
Returns
  • The group and/or child position for the given flat position in packed position representation.

public int getExpandedGroupsCount ()

Gets the number of expanded groups.

Returns
  • the number of expanded groups

public int getFlatPosition (long packedPosition)

Converts a group and/or child position to a flat position.

Parameters
packedPosition The group and/or child position to be converted in packed position representation.
Returns
  • The group and/or child position for the given flat position in packed position representation.

public int getGroupCount ()

Gets the number of groups.

Returns
  • the number of groups

public static long getGroupItemId (long rawId)

Gets group item ID from a raw ID.

Parameters
rawId raw item ID value (return value of getItemId())
Returns
  • Group item ID for the given raw item ID.

public static int getGroupViewType (int rawViewType)

Gets group view type from a raw view type.

Parameters
rawViewType raw view type value (return value of getItemViewType())
Returns
  • Group view type for the given raw view type.

public static int getPackedPositionChild (long packedPosition)

Gets the child position from a packed position. To get the group that this child belongs to, use getPackedPositionGroup(long). See getPackedPositionForChild(int, int).

Parameters
packedPosition The packed position from which the child position will be returned.
Returns
  • The child position portion of the packed position. If this does not contain a child, returns NO_POSITION.

public static long getPackedPositionForChild (int groupPosition, int childPosition)

Returns the packed position representation of a child position.

In general, a packed position should be used in situations where the position given to/returned from RecyclerViewExpandableItemManager method can either be a child or group. The two positions are packed into a single long which can be unpacked using getPackedPositionChild(long) and getPackedPositionGroup(long).

Parameters
groupPosition The child's parent group's position
childPosition The child position within the group
Returns
  • The packed position representation of the child (and parent group).

public static long getPackedPositionForGroup (int groupPosition)

Returns the packed position representation of a group's position. See getPackedPositionForChild(int, int).

Parameters
groupPosition The child's parent group's position.
Returns
  • The packed position representation of the group.

public static int getPackedPositionGroup (long packedPosition)

Gets the group position from a packed position. See getPackedPositionForChild(int, int).

Parameters
packedPosition The packed position from which the group position will be returned.
Returns
  • THe group position of the packed position. If this does not contain a group, returns NO_POSITION.

public Parcelable getSavedState ()

Gets saved state object in order to restore the internal state.

Call this method in Activity/Fragment's onSavedInstance() and save to the bundle.

Returns
  • The Parcelable object which stores information need to restore the internal states.

public boolean isAllGroupsCollapsed ()

Whether the all groups are expanded.

Returns
  • True if no group exists or every groups are collapsed, otherwise false.

public boolean isAllGroupsExpanded ()

Whether the all groups are expanded.

Returns
  • True if there is at least 1 group exists and every groups are expanded, otherwise false.

public boolean isGroupExpanded (int groupPosition)

Whether the given group is currently expanded.

Parameters
groupPosition The group to check
Returns
  • Whether the group is currently expanded

public static boolean isGroupItemId (long rawId)

Checks whether the passed item ID is a group's one.

Parameters
rawId raw item ID value (return value of getItemId())
Returns
  • True for the a group view type, otherwise false

public static boolean isGroupViewType (int rawViewType)

Checks whether the passed view type is a group's one.

Parameters
rawViewType raw view type value (return value of getItemViewType())
Returns
  • True for the a group view type, otherwise false

public boolean isReleased ()

Indicates this manager instance has released or not.

Returns
  • True if this manager instance has released

public void notifyChildItemChanged (int groupPosition, int childPosition, Object payload)

Notify any registered observers that the child item at {groupPosition, childPosition} has changed.

This is an item change event, not a structural change event. It indicates that any reflection of the data at {groupPosition, childPosition} is out of date and should be updated. The item at {groupPosition, childPosition} retains the same identity.

Parameters
groupPosition Position of the group item which contains the changed child
childPosition Position of the child item in the group that has changed
payload A non-null list of merged payloads. Can be empty list if requires full update.

public void notifyChildItemChanged (int groupPosition, int childPosition)

Notify any registered observers that the child item at {groupPosition, childPosition} has changed.

This is an item change event, not a structural change event. It indicates that any reflection of the data at {groupPosition, childPosition} is out of date and should be updated. The item at {groupPosition, childPosition} retains the same identity.

Parameters
groupPosition Position of the group item which contains the changed child
childPosition Position of the child item in the group that has changed

public void notifyChildItemInserted (int groupPosition, int childPosition)

Notify any registered observers that the group item reflected at groupPosition has been newly inserted. The group item previously at groupPosition is now at position groupPosition + 1.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPosition Position of the group item which contains the inserted child
childPosition Position of the newly inserted child item in the data set

public void notifyChildItemMoved (int fromGroupPosition, int fromChildPosition, int toGroupPosition, int toChildPosition)

Notify any registered observers that the child item reflected at fromGroupPosition, fromChildPosition has been moved to toGroupPosition, toChildPosition.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
fromGroupPosition Previous group position of the child item.
fromChildPosition Previous child position of the child item.
toGroupPosition New group position of the child item.
toChildPosition New child position of the child item.

public void notifyChildItemMoved (int groupPosition, int fromChildPosition, int toChildPosition)

Notify any registered observers that the child item reflected at groupPosition, fromChildPosition has been moved to groupPosition, toChildPosition.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPosition Group position of the child item.
fromChildPosition Previous child position of the child item.
toChildPosition New child position of the child item.

public void notifyChildItemRangeChanged (int groupPosition, int childPositionStart, int itemCount)

Notify any registered observers that the itemCount child items starting at position {groupPosition, childPosition} have changed.

This is an item change event, not a structural change event. It indicates that any reflection of the data in the given position range is out of date and should be updated. The items in the given range retain the same identity.

Parameters
groupPosition Position of the group item which contains the changed child
childPositionStart Position of the first child item in the group that has changed
itemCount Number of items that have changed

public void notifyChildItemRangeChanged (int groupPosition, int childPositionStart, int itemCount, Object payload)

Notify any registered observers that the itemCount child items starting at position {groupPosition, childPosition} have changed.

This is an item change event, not a structural change event. It indicates that any reflection of the data in the given position range is out of date and should be updated. The items in the given range retain the same identity.

Parameters
groupPosition Position of the group item which contains the changed child
childPositionStart Position of the first child item in the group that has changed
itemCount Number of items that have changed
payload A non-null list of merged payloads. Can be empty list if requires full update.

public void notifyChildItemRangeInserted (int groupPosition, int childPositionStart, int itemCount)

Notify any registered observers that the currently reflected itemCount child items starting at childPositionStart have been newly inserted. The child items previously located at childPositionStart and beyond can now be found starting at position childPositionStart + itemCount.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPosition Position of the group item which contains the inserted child
childPositionStart Position of the first child item that was inserted
itemCount Number of child items inserted

public void notifyChildItemRangeRemoved (int groupPosition, int childPositionStart, int itemCount)

Notify any registered observers that the itemCount child items previously located at childPositionStart have been removed from the data set. The child items previously located at and after childPositionStart + itemCount may now be found at oldPosition - itemCount.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPosition Position of the group item which was the parent of the child item that was removed
childPositionStart Previous position of the first child item that was removed
itemCount Number of child items removed from the data set

public void notifyChildItemRemoved (int groupPosition, int childPosition)

Notify any registered observers that the child item previously located at childPosition has been removed from the data set. The child items previously located at and after childPosition may now be found at oldGroupPosition - 1.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPosition Position of the group item which was the parent of the child item that was removed
childPosition Position of the child item that has now been removed

public void notifyChildrenOfGroupItemChanged (int groupPosition, Object payload)

Notify any registered observers that the children items contained in the group item at groupPosition have changed.

This is an group item change event, not a structural change event. It indicates that any reflection of the data at groupPosition is out of date and should be updated. The item at groupPosition retains the same identity.

This method does not notify for the group item. If the group has also changed, use notifyGroupAndChildrenItemsChanged(int) instead.

Parameters
groupPosition Position of the group item which contains changed children
payload A non-null list of merged payloads. Can be empty list if requires full update.

public void notifyChildrenOfGroupItemChanged (int groupPosition)

Notify any registered observers that the children items contained in the group item at groupPosition have changed.

This is an group item change event, not a structural change event. It indicates that any reflection of the data at groupPosition is out of date and should be updated. The item at groupPosition retains the same identity.

This method does not notify for the group item. If the group has also changed, use notifyGroupAndChildrenItemsChanged(int) instead.

Parameters
groupPosition Position of the group item which contains changed children

public void notifyGroupAndChildrenItemsChanged (int groupPosition)

Notify any registered observers that the group and children items at groupPosition have changed.

This is an group item change event, not a structural change event. It indicates that any reflection of the data at groupPosition is out of date and should be updated. The item at groupPosition retains the same identity.

Parameters
groupPosition Position of the group item which contains changed children

public void notifyGroupAndChildrenItemsChanged (int groupPosition, Object payload)

Notify any registered observers that the group and children items at groupPosition have changed.

This is an group item change event, not a structural change event. It indicates that any reflection of the data at groupPosition is out of date and should be updated. The item at groupPosition retains the same identity.

Parameters
groupPosition Position of the group item which contains changed children
payload A non-null list of merged payloads. Can be empty list if requires full update.

public void notifyGroupItemChanged (int groupPosition, Object payload)

Notify any registered observers that the group item at groupPosition has changed with an optional payload object.

This is an group item change event, not a structural change event. It indicates that any reflection of the data at groupPosition is out of date and should be updated. The item at groupPosition retains the same identity.

This method does not notify for children that are contained in the specified group. If children have also changed, use notifyGroupAndChildrenItemsChanged(int, Object) instead.

Client can optionally pass a payload for partial change. These payloads will be merged and may be passed to adapter's onBindGroupViewHolder(RecyclerView.ViewHolder, int, int, List) if the item is already represented by a ViewHolder and it will be rebound to the same ViewHolder. A notifyItemRangeChanged() with null payload will clear all existing payloads on that item and prevent future payload until onBindGroupViewHolder(RecyclerView.ViewHolder, int, int, List) is called. Adapter should not assume that the payload will always be passed to onBindGroupViewHolder(), e.g. when the view is not attached, the payload will be simply dropped.

Parameters
groupPosition Position of the group item that has changed
payload Optional parameter, use null to identify a "full" update

public void notifyGroupItemChanged (int groupPosition)

Notify any registered observers that the group item at groupPosition has changed.

This is an group item change event, not a structural change event. It indicates that any reflection of the data at groupPosition is out of date and should be updated. The item at groupPosition retains the same identity.

This method does not notify for children that are contained in the specified group. If children have also changed, use notifyGroupAndChildrenItemsChanged(int) instead.

Parameters
groupPosition Position of the group item that has changed

public void notifyGroupItemInserted (int groupPosition, boolean expanded)

Notify any registered observers that the group item reflected at groupPosition has been newly inserted. The group item previously at groupPosition is now at position groupPosition + 1.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPosition Position of the newly inserted group item in the data set
expanded Whether the groups will be inserted already expanded

public void notifyGroupItemInserted (int groupPosition)

Notify any registered observers that the group item reflected at groupPosition has been newly inserted. The group item previously at groupPosition is now at position groupPosition + 1.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPosition Position of the newly inserted group item in the data set

public void notifyGroupItemMoved (int fromGroupPosition, int toGroupPosition)

Notify any registered observers that the group item reflected at fromGroupPosition has been moved to toGroupPosition.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
fromGroupPosition Previous position of the group item.
toGroupPosition New position of the group item.

public void notifyGroupItemRangeInserted (int groupPositionStart, int itemCount, boolean expanded)

Notify any registered observers that the currently reflected itemCount group items starting at groupPositionStart have been newly inserted and may be expanded. The group items previously located at groupPositionStart and beyond can now be found starting at position groupPositionStart + itemCount.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPositionStart Position of the first group item that was inserted
itemCount Number of group items inserted
expanded Whether the groups will be inserted already expanded

public void notifyGroupItemRangeInserted (int groupPositionStart, int itemCount)

Notify any registered observers that the currently reflected itemCount group items starting at groupPositionStart have been newly inserted. The group items previously located at groupPositionStart and beyond can now be found starting at position groupPositionStart + itemCount.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPositionStart Position of the first group item that was inserted
itemCount Number of group items inserted

public void notifyGroupItemRangeRemoved (int groupPositionStart, int itemCount)

Notify any registered observers that the itemCount group items previously located at groupPositionStart have been removed from the data set. The group items previously located at and after groupPositionStart + itemCount may now be found at oldPosition - itemCount.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPositionStart Previous position of the first group item that was removed
itemCount Number of group items removed from the data set

public void notifyGroupItemRemoved (int groupPosition)

Notify any registered observers that the group item previously located at groupPosition has been removed from the data set. The group items previously located at and after groupPosition may now be found at oldGroupPosition - 1.

This is a structural change event. Representations of other existing items in the data set are still considered up to date and will not be rebound, though their positions may be altered.

Parameters
groupPosition Position of the group item that has now been removed

public void release ()

Detach the androidx.recyclerview.widget.RecyclerView instance and release internal field references.

This method should be called in order to avoid memory leaks.

public void restoreState (Parcelable savedState)

Restore saves state. See restoreState(android.os.Parcelable, boolean, boolean). (This method does not invoke any hook methods and listener events)

Parameters
savedState The saved state object

public void restoreState (Parcelable savedState, boolean callHooks, boolean callListeners)

Restore saves state.

This method is useful when the adapter can not be prepared (because data loading may takes time and processed asynchronously) before creating this manager instance.

Parameters
savedState The saved state object
callHooks Whether to call hook routines (onHookGroupExpand(int, boolean, Object), onHookGroupCollapse(int, boolean, Object))
callListeners Whether to invoke RecyclerViewExpandableItemManager.OnGroupExpandListener and/or RecyclerViewExpandableItemManager.OnGroupCollapseListener listener events

public void scrollToGroup (int groupPosition, int childItemHeight)

Scroll to a group.

Parameters
groupPosition Position of the group item
childItemHeight Height of each child item height

public void scrollToGroup (int groupPosition, int childItemHeight, int topMargin, int bottomMargin, AdapterPath path)

Scroll to a group.

Parameters
groupPosition Position of the group item
childItemHeight Height of each child item height
topMargin Top margin
bottomMargin Bottom margin
path Adapter path for the wrapped adapter returned by the createWrappedAdapter(RecyclerView.Adapter).

public void scrollToGroup (int groupPosition, int childItemHeight, int topMargin, int bottomMargin)

Scroll to a group.

Parameters
groupPosition Position of the group item
childItemHeight Height of each child item height
topMargin Top margin
bottomMargin Bottom margin

public void scrollToGroupWithTotalChildrenHeight (int groupPosition, int totalChildrenHeight, int topMargin, int bottomMargin)

Scroll to a group with specifying total children height.

Parameters
groupPosition Position of the group item
totalChildrenHeight Total height of children items
topMargin Top margin
bottomMargin Bottom margin

public void scrollToGroupWithTotalChildrenHeight (int groupPosition, int totalChildrenHeight, int topMargin, int bottomMargin, AdapterPath path)

Scroll to a group with specifying total children height.

Parameters
groupPosition Position of the group item
totalChildrenHeight Total height of children items
topMargin Top margin
bottomMargin Bottom margin
path Adapter path for the wrapped adapter returned by the createWrappedAdapter(RecyclerView.Adapter).

public void setDefaultGroupsExpandedState (boolean expanded)

Sets default group items expanded state

Parameters
expanded default group expanded state (true: expanded, false: collapsed)

public void setOnGroupCollapseListener (RecyclerViewExpandableItemManager.OnGroupCollapseListener listener)

Register a callback to be invoked when an group item has been collapsed.

Parameters
listener The callback that will be invoked.

public void setOnGroupExpandListener (RecyclerViewExpandableItemManager.OnGroupExpandListener listener)

Register a callback to be invoked when an group item has been expanded.

Parameters
listener The callback that will be invoked.