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

Fix drag & drop issues in SimpleDragCallback #985

Merged
merged 5 commits into from
Mar 17, 2021

Conversation

cketti
Copy link
Contributor

@cketti cketti commented Mar 16, 2021

This fixes a couple of issues in SimpleDragCallback (see individual commits) and adds a new activity showing off how to reorder (parts of) a list.

FastAdapter_reorder_list.mp4

cketti added 5 commits March 16, 2021 21:27
Previously SimpleDragCallback.getDragDirs() would allow dragging items that didn't implement IDraggable. Now such items are treated like ones that implement IDraggable but have 'isDraggable' set to false.
When dragging an item developers can prevent it from changing its position in the list by returning false from ItemTouchCallback.itemTouchOnMove(). This change only updates the 'to' property after an item has been moved successfully. Without this change the wrong 'newPosition' value could be delivered to ItemTouchCallback.itemTouchDropped().
When using ItemTouchHelper.startDrag() it's possible to get into a state where SimpleDragCallback.clearView() of the dropped item is called after the drag for the next item has already started. By this time the 'from' and 'to' values no longer refer to the item that was just dropped. So the wrong values are delivered to ItemTouchCallback.itemTouchDropped().
To clear the visual highlight from a dropped item a new callback method ItemTouchCallback.itemTouchStopDrag() is introduced.
Display a list where a subset of items can be reordered using a drag handle.
@mikepenz
Copy link
Owner

That's amazing. thank you so much for the PR. will look into it asap

@mikepenz mikepenz self-requested a review March 17, 2021 08:09
@mikepenz
Copy link
Owner

I believe danger is failing because of this coming from a fork and it ain't have the right permission to run :/ will look into that seperately

@mikepenz mikepenz merged commit 9388e1e into mikepenz:develop Mar 17, 2021
@mikepenz
Copy link
Owner

Once again. thank you so much for the great PR. Released it as v5.4.0-b01 in case it's blocking the PR you have open on k-9 mail

@cketti cketti deleted the fix_drag_and_drop_issues branch March 17, 2021 15:15
@cketti
Copy link
Contributor Author

cketti commented Mar 17, 2021

Once again. thank you so much for the great PR. Released it as v5.4.0-b01 in case it's blocking the PR you have open on k-9 mail

Awesome. Thanks ❤️

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

Successfully merging this pull request may close these issues.

2 participants