h6ah4i / android-advancedrecyclerview

RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)
https://advancedrecyclerview.h6ah4i.com/
Apache License 2.0
5.31k stars 862 forks source link

Swipe right to remove animation gone #320

Open cwfei opened 7 years ago

cwfei commented 7 years ago

Hi there, I have problems implementing the Basic Swipe, I read your sample project over and over again and still I can't figure out the issues. Whenever I swiping an item to the right to remove it, the item will be removed before the animation finish. Fyi, I have no problem with stableIds.

Here's the video for your better understanding https://youtu.be/ZUGOsEykDgM

h6ah4i commented 7 years ago

@cwfei Hi. This library expects stable ID for swiping feature, and it seems that your adapter does not support stable IDs properly.

  @Override
    public long getItemId(int position) {
        // return position; <- this is not stable!

        // should returns stable value. IDs have to be kept the same value 
        // even after its position has been changed.
        return mItems.get(position).getId();
    }

related issues:

cwfei commented 7 years ago

Thanks for reply, I'm confused with stableIds, what kind of ids should I return? Currently I'm returning the primary key (Id) of every item, is it correct?

h6ah4i commented 7 years ago

primary key (Id) of every item

Sorry, I thought the behavior looked exactly the same as when the adapter just returning position. If they keeps the same value after removing an item, that would be perfect for item IDs.

Do you use custom ItemAnimator or any other RecyclerView extension libraries?

cwfei commented 7 years ago

I didn't use any recyclerview extension libraries and only use the animator that included in your sample.

h6ah4i commented 7 years ago

Hi. Any progress on this? I have not reproduced it yet and I have no idea to solve this 😥

cwfei commented 7 years ago

Hi there, this is my latest result, https://youtu.be/7lGDjUfFVNM

Unfortunately I still can't get it working properly.

h6ah4i commented 7 years ago

Thanks for the new video, it helps me a lot! I noticed that the issue only present when the list does not have sufficient items to fill the whole of screen. It seems you are using wrap_content for RecyclerView, but I guess swipe dismiss animation won't work well in this situation. I'll try to reproduce it later and find any workarounds.

EDIT: