Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
chouex opened this issue Aug 26, 2015 · 2 comments
Closed

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

chouex opened this issue Aug 26, 2015 · 2 comments

Comments

@chouex
Copy link

@chouex chouex commented Aug 26, 2015

//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)

@yqritc

This comment has been minimized.

Copy link
Owner

@yqritc yqritc commented Aug 26, 2015

@chouex
yes, your are right.
Maybe I will simply change EnumMapBindAdapter as following.

if (binderPosition < 0)

I'll fix it in next release

@yqritc

This comment has been minimized.

Copy link
Owner

@yqritc yqritc commented Aug 27, 2015

@chouex
I published v 1.1.0 fixed the above issue

@yqritc yqritc closed this Aug 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.