woxblom / DragListView

Drag and drop to reorder items in a list, grid or board for Android. Based on RecyclerView. Also supports swiping items in a list.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Return the item to its place if the user dragged it to another column.

osmovia opened this issue · comments

Hello. Thanks for the library, very nice project. This is exactly what I was looking for.

Please let me know how I can achieve the following case:
The user should not drag and drop items into the specific column.
Let 's assume we have 3 columns and we can drag items from 1st column to the rest columns. But we shouldn't able to drag from 2nd and 3rd to 1st.
I managed to implement this logic, however, when I drag item from 3rd to 1st, the item is moved to the 2nd column instead of its initial place.

I've attached a video for better understanding.

Screen.Recording.2022-07-06.at.6.30.54.PM.mov

Thanks in advance!

Hey, the issue happens because you are allowing an item to be moved from column 3 to column 2. As you can see in the video when you move an item from column 3 and then over to column 1 it moves into (you see the empty space is moved) place in column 2 before moving it to column 1.

So you need to implement so you can only move stuff from column 1. Never from any other column. Or should you be able to move an item from column 3 to column 2 by the way?

Hi @woxblom,

Thx for prompt answer. Yes, you are able to move item from 2nd to 3rd and vice versa. But once you've moved item from 1st column, you shouldn't be able to move it back (to 1st), only between 2nd and 3rd columns.

Yeah if that is the case then it will be pretty hard to fix the issue you are describing as the lib will move the item to the last valid position it was in. And when you drag from column 3 over column 2 to column 1 it will see column 2 as a valid position.

You would need to do some own logic to fix this. You could track where the item is outside the lib with the callbacks for example and if the item is released above an invalid column you could move it manually back to the first position which you then need to keep track of outside the lib.

Thanks for the help.

Screen.Recording.2022-07-06.at.8.34.39.PM.mov