Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Wrong item removed from list in UI #16

Closed
gr3ger opened this issue Nov 4, 2016 · 6 comments · Fixed by #18
Closed

Wrong item removed from list in UI #16

gr3ger opened this issue Nov 4, 2016 · 6 comments · Fixed by #18
Assignees
Labels

Comments

@gr3ger
Copy link

gr3ger commented Nov 4, 2016

The library doesn't seem to take headers into account when removing items.

When I do adapter.remove(item);
It will remove the item before that if I have a header, and if I remove the very first item, it crashes with the following stacktrace:

11-04 14:20:05.422 10076-10076/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: se.thefarm.yourblock, PID: 10076
                                                   java.lang.IllegalArgumentException: Called attach on a child which is not detached: ViewHolder{49e503 position=0 id=-1, oldPos=-1, pLpos:-1}
                                                       at android.support.v7.widget.RecyclerView$5.attachViewToParent(RecyclerView.java:692)
                                                       at android.support.v7.widget.ChildHelper.attachViewToParent(ChildHelper.java:239)
                                                       at android.support.v7.widget.RecyclerView.addAnimatingView(RecyclerView.java:1178)
                                                       at android.support.v7.widget.RecyclerView.animateDisappearance(RecyclerView.java:3535)
                                                       at android.support.v7.widget.RecyclerView$4.processDisappeared(RecyclerView.java:456)
                                                       at android.support.v7.widget.ViewInfoStore.process(ViewInfoStore.java:246)
                                                       at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3385)
                                                       at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3135)
                                                       at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1549)
                                                       at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:305)
                                                       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                                                       at android.view.Choreographer.doCallbacks(Choreographer.java:580)
                                                       at android.view.Choreographer.doFrame(Choreographer.java:549)
                                                       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
                                                       at android.os.Handler.handleCallback(Handler.java:739)
                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                       at android.os.Looper.loop(Looper.java:135)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

@zplesac
Copy link
Member

zplesac commented Nov 4, 2016

Hi @gr3ger, thanks for the reported issue, I'll look into it.

@zplesac zplesac self-assigned this Nov 4, 2016
@gr3ger
Copy link
Author

gr3ger commented Nov 4, 2016

It seems to apply to all itemAnimator effects, both insertion and removal (on top of the crashing issue)

I haven't looked too much into it, but I suspect it has something to do with the library not taking headers into account when calculating indices :P

But so far, really a solid library, keep up the good work!

@zplesac
Copy link
Member

zplesac commented Nov 4, 2016

Just to double check - you are using latest 1.1.0 version?

@gr3ger
Copy link
Author

gr3ger commented Nov 4, 2016

Yes, I'm using the latest version.
compile 'co.infinum:mjolnirrecyclerview:1.1.0@aar'

@zplesac
Copy link
Member

zplesac commented Nov 4, 2016

You are right, some of the methods don't take headers into account when adding/removing items from the adapter.

I'll prepare PR with bug fixes, and we'll include this into next version release.

@zplesac zplesac added bug and removed investigate labels Nov 4, 2016
@gr3ger
Copy link
Author

gr3ger commented Nov 4, 2016

Great, thanks mate :)
I think I found another issue aswell regarding empty views, but I'll make a new topic of that once I make sure I'm not doing some mistake somewhere.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants