airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.52k stars 726 forks source link

Rearrangeable support #165

Closed elihart closed 7 years ago

elihart commented 7 years ago

We are working on a small addition to Epoxy to better allow for using item touch interceptors for rearranging or swiping models.

This will come in a future 2.x release

Sroka commented 7 years ago

Yes, please :)

This is the only missing feature that is keeping me from moving to epoxy

elihart commented 7 years ago

@Sroka Thanks for the feedback. what exactly would you like to see in this? swiping? drag and drop rearranging? something more? The more details you can give us the better we can design this for other people's needs.

What we're probably going to end up with is a subclass of item touch helper that helps deal with the epoxy models, and possibly interfaces to automatically call back to models that have been touched. We are leaning towards a simpler system like this so we can keep it very flexible

thenickreynolds commented 7 years ago

Since there's additional interest I can put some time into this. Won't take much and current time consumers are winding down.

On Sat, Apr 1, 2017, 10:48 AM Eli Hart notifications@github.com wrote:

@Sroka https://github.com/Sroka Thanks for the feedback. what exactly would you like to see in this? swiping? drag and drop rearranging? something more? The more details you can give us the better we can design this for other people's needs.

What we're probably going to end up with is a subclass of item touch helper that helps deal with the epoxy models, and possibly interfaces to automatically call back to models that have been touched. We are leaning towards a simpler system like this so we can keep it very flexible

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/airbnb/epoxy/issues/165#issuecomment-290935850, or mute the thread https://github.com/notifications/unsubscribe-auth/AFspdG33Uck3X2caNldOEGsNYlNEG77jks5rro3OgaJpZM4Mlqio .

elihart commented 7 years ago

Thanks @thenickreynolds! let me know if I can help

Sroka commented 7 years ago

@elihart Well, those APIs of RecyclerView are quite tricky to handle properly. Mostly it is coming from a lot of combinations that has to be handled. Like, what should happen when:

While using other libraries I found that keeping the state of underlying data can be tricky. For example, User drags&drops item to some other place. We then, usually, make a request to our server that puts rearranged data there. Request can end with 200 what means items should be kept as user rearranged them or with some error and items should be put back on their places. The same goes for swiping.

Additionally, when item is swiped out gmail app, for example, leaves in place of an item a button for user to undo archive action. Being able to handle something like this would be nice.

elihart commented 7 years ago

@Sroka Thanks for the details! sounds like you're not looking for a specific use case, you just want good general support for touch.

You're right that there are many combinations and settings to use with the touch API's. You also mentioned a swipable view that shows a different view behind it as you swipe, as well as trickiness with updating data.

Since those are all so use case specific it isn't something I want to solve with Epoxy. Instead I want to make the touch API's epoxy specific, so it is easy to get Epoxy models, views, and work with the adapter. Ideally we can make it easier to have the models and adapters aware of the touch events. However, I want to leave it open ended from there so we don't limit people, and then there is room to use anything you want on top of that.

At the very least we will provide touch helper implementations for rearranging (and maybe swiping), but those won't try to solve every use case and will serve as both an example and a generic base solution.

ghost commented 7 years ago

Asking a question,Is the epoxy not support for the ItemTouchHelper's API yet?

elihart commented 7 years ago

@lemon-yang Epoxy works perfectly fine with item touch helper, but you have to set it all up manually from scratch (just like working with any recyclerview). We can instead provide a few tools to make it easier to work with, as well as some examples.

elihart commented 7 years ago

will be released in next version