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

Swipe right to remove animation gone #320

Open
cwfei opened this issue Nov 10, 2016 · 7 comments
Open

Swipe right to remove animation gone #320

cwfei opened this issue Nov 10, 2016 · 7 comments
Labels

Comments

@cwfei
Copy link

cwfei commented Nov 10, 2016

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
Copy link
Owner

h6ah4i commented Nov 10, 2016

@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
Copy link
Author

cwfei commented Nov 11, 2016

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
Copy link
Owner

h6ah4i commented Nov 11, 2016

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
Copy link
Author

cwfei commented Nov 11, 2016

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

@h6ah4i
Copy link
Owner

h6ah4i commented Nov 14, 2016

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

@cwfei
Copy link
Author

cwfei commented Nov 19, 2016

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

Unfortunately I still can't get it working properly.

@h6ah4i
Copy link
Owner

h6ah4i commented Nov 20, 2016

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:

  • Workaround - 1 (recommended)
    • Use match_parent for RecyclerView.
  • Workaround - 2
    • Make the adapter returns a spacer item for the last item.

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

No branches or pull requests

2 participants