Skip to content

wrong position for getPosition(DataBinder binder, int binderPosition) #6

@chouex

Description

@chouex
//TYPE1
public void bindViewHolder(ViewHolder holder, int position) {
            Log.w("bindViewHolder",position+" "+getPosition(this,position));
}

0 1
1 1
2 2
3 3
should be:
0 1
1 2
2 3
3 4

data example:
TYPE0
TYPE1
TYPE1
TYPE1

in getPosition

                --binderPosition;
                if(binderPosition <= 0) {

when positionOfBinder==0, after1 loop, -1<=0 so return 1 (correct)
when positionOfBinder==1, after1 loop, 0<=0 so return 1 (wrong, it should be 2)

i think binderPosition should not <0, so i fix it with

                if(binderPosition-- <= 0) {

when positionOfBinder==0, after1 loop, 0<=0 so return 1 (correct)
when positionOfBinder==1, first loop 1<=0 is false , second loop, 0<=0 so return 2 (correct)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions