Skip to content

Commit

Permalink
Add commit about itemViewType.
Browse files Browse the repository at this point in the history
  • Loading branch information
pokercc committed Jan 17, 2021
1 parent b7ee5de commit b126fba
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,22 @@ abstract class ExpandableAdapter<VH : ExpandableAdapter.ViewHolder> : RecyclerVi
}
}

/**
* Must be positive .
* See also [isGroup]
*/
open fun getGroupItemViewType(groupPosition: Int): Int = 1

/**
* Must be negative or zero .
* See also [isGroup]
*/
open fun getChildItemViewType(groupPosition: Int, childPosition: Int): Int = -1

/**
* Distinguish group item or child item by viewType.
* By default groupViewType is positive , childViewType is negative or zero.
*/
open fun isGroup(viewType: Int): Boolean = viewType > 0

final override fun onBindViewHolder(viewHolder: VH, position: Int) = Unit
Expand Down

0 comments on commit b126fba

Please sign in to comment.