修复插入图片再拖拽导致图片无法删除的问题 #1
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在相册中添加一张本地图片,然后拖拽本地图片将其移动到中间位置,比如从下标6移动到下标4,接着再移除第5和第6张图片,其中有一种会无法移除,这是因为使用
Collections.swap替换位置后会导致图片下标错乱,从如下的日志可以清楚看到:正确的结果应该是下标 6 移动到下标 4 后,原来的 4 和 5 依次变成 5 和 6,但只替换的话原来的 5 没有变化。由于删除时是按照下标删除的,会导致删除出错。所以拖拽后应该先将移动的图片从集合中移除,再插入相应的位置。