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

拖动展示列表跟实际数据列表不一致 #329

Open
yeagle2468 opened this issue Jan 6, 2024 · 0 comments
Open

拖动展示列表跟实际数据列表不一致 #329

yeagle2468 opened this issue Jan 6, 2024 · 0 comments

Comments

@yeagle2468
Copy link

不知道为何,这个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有问题

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

No branches or pull requests

1 participant