Closed kientux closed 8 years ago
I have fixed it! @Override public void onBindViewHolder(UltimateRecyclerviewViewHolder viewHolder, int position) { // int binderPosition = getBinderPosition(position);//Remove-No no need //Hung fixed getDataBinder(viewHolder.getItemViewType()).bindViewHolder(viewHolder, position);
}
+1 on this. @cymcsg if you think the fix here is correct I can PR with the fix.
@netanelgilad @hungnguyenvan All of you think that is correct ,aren't you? I hope the PR of the problem.
First, sorry for my bad English.
I was successfully implement
UltimateDifferentViewTypeAdapter
to support multiple view type in recycler view (I have 3 view types). But in this method:position
here is not the position ofMyViewHolder
in recycler view. If I get object fromdataList
with that position, the object might be wrong.For example, I have an array: [1, a, 2, b, 3, c] with 2 view types
NumberViewHolder
andCharacterViewHolder
.position
inDataBinder
ofNumberViewHolder
will be 0 - 1 - 2; and it supposed to be 0 - 2 - 4.position
inDataBinder
ofCharacterViewHolder
will be 0 - 1 - 2; and it supposed to be 1 - 3 - 5.I mean, it's like you split the array into 2 array based on which view type, then get position from each array, not from original array.
In your example app,
MultiViewTypesActivity
shows each data two times because of this. I don't know if this is a bug or just the code design?