-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
拖动展示列表跟实际数据列表不一致 #329
Comments
目前的演示代码中,都是相邻两个元素进行交换,所以不会出现你说的问题: === DragGridActivity === === DragTouchListActivity === |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
不知道为何,这个bug一直没人提,原因出在这里:
Collections.swap(data, fromPosition, toPosition); // 这里是交换 fromPosition 的数据跟 toPosition数据进行交换
adapter.notifyItemMoved(fromPosition, toPosition); // 这里是将fromPosition 的移动到 toPosition
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
当fromPosition跟toPosition是临近的则没有问题,如9移动到8,正常;但当9直接移动到7就错了,展示的数据是[0, 1, 2, 3, 4, 5, 6, 9, 7, 8],而如果直接使用Collections.swap,则实际数据是 [0, 1, 2, 3, 4, 5, 6, 9, 8, 7],就会导致不一致,所有这里使用Collections.swap有问题
The text was updated successfully, but these errors were encountered: