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.
Apache License 2.0
693 stars 177 forks source link

Want to learn this library.Can you give some suggest? #173

Closed qazxcs113 closed 3 years ago

qazxcs113 commented 4 years ago

This is a excellent library.I can Convenient use it. But i not just want to use it . I want learn more how to build and design it. Can you give me some suggest?

I jsut know that DragListView maybe is middle layer. DragRecyclerView is hold List. DragItemAdapter is RecycView Adapter. DragItem is item for dragimage.

By the way,I don't know which function hide the original view... if you have time,I want to learn it.thanks

woxblom commented 3 years ago

Hey, thanks glad you like it! :)

Hm well, you are correct that the DragListView is the view that is exposed to the lib user. DragRecyclerView is the actual recyclerview that is used by the the DragListView and the DragItemAdapter is the adapter. The DragItem is the item that will be visible ontop of everything when dragging, this is a view that is put on top of the DragListView and when it is visible I hide the item in the adapter that is being dragged.

So in genereal what is happening is that when the drag and drop starts the view in the adapter is hidden and the DragItem view is shown and is then following the finger. When moving across items in the recyclerview items in the adapter is moved around to follow the finger which will result in the empty space in the adapter being moved with the finger. So I detect where the finger is on the screen and move items around in the adapter based on that.