hudomju / android-swipe-to-dismiss-undo

Android swipe-to-dismiss-undo library and sample code
MIT License
239 stars 84 forks source link

Undo view drops 1 position on swipe #17

Open AlexBurk opened 8 years ago

AlexBurk commented 8 years ago

Hi,

I'm facing one problem with your library.

Lets say I have a list with objects counting numbers 1, 2, 3, 4, 5. I now swipe "2" aside and "undo" shows up. As soon as I delete "3" (or any other item below "2"), the "2" correctly disappears and the "undo" of "3" appears. But as soon as the animation is over the "undo" drops one position on 4 and 3 is displayed again. Now when i Scroll the list updates correctly, the 3 is gone and 4 is displayed.

swipe

I don't know whats going on here :/ Someone any idea where I can start?

Cheers

Josephtsessions commented 8 years ago

This is happening to me as well - I'd love to use the library, but I'm wary because of this. I'm hoping it's just user-error - anyone know what's up?

abdurrahmanbmf commented 8 years ago

instead of writing adapter.remove(position);

in onDismiss overridden method do:

listOfObjectsForRecyclerView.remove(position); adapter.notifyItemRemoved(position);

Josephtsessions commented 8 years ago

@abdurrahmanbmf

In my custom adapter, I have: public void remove(int position) { items.remove(position); notifyDataSetChanged(); }

notifyItemRemoved doesn't seem to be available for the adapter (which extends BaseAdapter), but I'm using a listview. Calling remove like this still results in this weird behavior per list item. Do you have a complete code snippet I can take a look at?

Thanks for the help!

AlexBurk commented 8 years ago

It's been a while but I remeber a collegue said it works with recyclerview and doesn't with listview.. So try Recyclerview instead listview and post results ;-)

FahadQurashi49 commented 8 years ago

I'm facing the same problem have anyone found its solution? I'm using ListView.

miguelscudeller commented 8 years ago

the solution I used was change it to RecyclerView maybe this article might help you do that http://andraskindler.com/blog/2014/migrating-to-recyclerview-from-listview/