drakeet / MultiType

Flexible multiple types for Android RecyclerView.
Apache License 2.0
5.76k stars 751 forks source link

it maybe much properer to add Position param in the Method#onBindViewHolder . #229

Closed FYSong closed 6 years ago

FYSong commented 6 years ago

What kind of issue is this?

Info:
Description:
Reproduction Steps:
My thoughts:
What did I do:
drakeet commented 6 years ago

You should use the ViewHolder to get position. And as Android official document says:

Note that unlike ListView, RecyclerView will not call this method again if the position of the item changes in the data set unless the item itself is invalidated or the new position cannot be determined. For this reason, you should only use the position parameter while acquiring the related data item inside this method and should not keep a copy of it. If you need the position of an item later on (e.g. in a click listener), use getAdapterPosition() which will have the updated adapter position. Override onBindViewHolder(ViewHolder, int, List) instead if Adapter can handle efficient partial bind.