Closed mattiasbe closed 8 years ago
@mattiasbe hi. thanks for your suggestion.
I am afraid this feature is "out-of-scope" of this library. The FastAdapter is here to manage your items, to provide all the API's you need for selection, expandable items. It allows you to add, remove, move, change items. And provides all the required methods to make your RecyclerView
as fast as possible.
The FastAdapter also provides the Item
s interface, which contains the methods how to display a specific item
, but itself does not know about how an item
looks like.
So having an item
which provides the above logic is in the scope of the dev using the library.
I would love to have something like this in the sample. But right now I do not see this in the core of the FastAdapter
may as additional addon.
Surely I would love to see a pull request adding something like this to the sample.
There are also already other libraries out which implement this kind of behavior. https://github.com/daimajia/AndroidSwipeLayout
@mikepenz I understand completely, I initially dismissed the idea of creating the RFE for that exact reason (out of scope), but figured I had to ask anyway since the UndoHelper with the Snackbar undo UI is there in the project.
I've used that library in a few projects, including one with FastAdapter now. Never combined that particular project with the swipe to dismiss/remove though, just to reveal actions. Maybe it can be done, but as that is not the purpose of that library I prefer not to (ab)use it that way. Rarely ends up well further down the lifetime of the projects (again makes me thankful you have very focused libraries).
By the way for anyone wishing to use that swipe library with FastAdapter, please note that to get the swipe and click to work together, don't use the withOnClickListener from FastAdapter, instead set it on the item yourself (at viewholder creation time), and make sure to set the onClickListener on the top surface only.
I'll see what I can find time for. Thanks for another great library and support.
Maybe you want to add an example?
@mattiasbe thanks for the detailed answer. If you find some time for a PR... just open it ;). I would really love to have something like this in the sample
Looked into adding it into the sample app a little bit. Raises a few questions, multiple ways to do it, api design, not adding any support into the FastAdapter or doing so, how customizable, all features, or just parts and if so make it easy to use some of it (only leave behinds, no actions, only actions, only swipe). Ability to combine with drag.
Question 4 below pretty much sums it up about what I'm currently consider implementing for the sample app if anyone would be interested.
@mikepenz What would your preferred way of discussing for example API alternatives be (even for sample app only stuff)? Nothing major just that I prefer iterating/feedbacking it with someone.
Initial questions:
@mattiasbe I would suggest to make better a new example - than merging all together. Could end up a bit confusing. :)
Would be also better to discuss....PR...
@Rainer-Lang I forked and started some work on it. Can see the current state in the fork, I'll do a PR to get feedback at some point(s). From the state of my fork at the moment I'll next:
See the attached screen cap for the current state of the implementation:
Looks awesome.
@mattiasbe sorry for not yet answering your questions. The preview video you have added looks already really promising
Looking at your current implementation, it really might be something I would add to the core. Really clean, and also works without deep wires, so it stays very flexible.
I really like it!
Thanks for your kind words @mikepenz Current state:
There are some api issues that can be tweaked etc, and could benefit from some support in the actual lib, like a Swipeable interface and support for that for easier API and built in features. Instead of having to add such a pattern by yourself (no example of a Swipeable interface given there yet, it's implicit only). The use/setting of swipedActionRunnnable is a bit clunky and could benefit from this.
But maybe good enough for a sample now so will do a PR, hopefully tomorrow, and later on it can be improved or even partly added to the core.
@mattiasbe I added notes to the PR. The changes are fine, but it seems like you merged the master
into the develop
which resulted in all the releases being part of the PR
so i can't merge it :/
@mattiasbe the base is now part of the fastadapter-extensions
module. Now we can improve the API. or even add deeper integration (as far as possible without altering the FastAdapter
)
Excellent :smile: @mikepenz
Will close this now as the base is included. I'm still open for improvements ;). But this might should find a new issue or PR then ;)
Request for enhancement: Swipe remove with in-place undo and "leave-behind" The UndoHelper is great (snackbar undo of removal of item), but Gmail and other apps have a swipe to remove/archive/whatever that instead of showing a snackbar with UNDO shows what happened "in-place" where that item was along with providing an UNDO action "in-place" where the item used to be. Furthermore, starting the swipe reveals an icon indicating what will happen if swiping further (and in some implementations also colors the background accordingly, red for deleting etc).
See also the material design guidelines ragarding "leave-behinds" for indicating what happens when swiping: https://www.google.com/design/spec/components/lists-controls.html#lists-controls-types-of-list-controls Scroll down to "leave-behinds".
Implementation idea for a first shot at it could be to enable a choice of swipe directions in the ItemTouchHelper. Upon swipe of item, swap out the displayed item in the adapter and replace back that on timeout similar to the current UndoHelper. The replaced item could have an action. Of course handling the "leave-behinds" requires better integration with the actual swipe.