| | |
| | | //处理从相册返回时取消的图片处理 |
| | | existingPaths.removeAll(resultPaths); |
| | | if (!existingPaths.isEmpty()) { |
| | | List<UplodFileState> toRemove = new ArrayList<>(); |
| | | for (String path : existingPaths) { |
| | | for (UplodFileState uplodFileState : uplodFileStates) { |
| | | if (path.equals(uplodFileState.getFilePath())) { |
| | | uplodFileState.getThisCall().cancel(); |
| | | uplodFileStates.remove(uplodFileState); |
| | | toRemove.add(uplodFileState); |
| | | } |
| | | } |
| | | } |
| | | uplodFileStates.removeAll(toRemove); |
| | | } |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | boolean isMaxSize = result.size() == mAdapter.getSelectMax(); |
| | | int oldSize = mAdapter.getData().size(); |
| | | mAdapter.notifyItemRangeRemoved(0, isMaxSize ? oldSize + 1 : oldSize); |
| | | mAdapter.getData().clear(); |
| | | runOnUiThread(() -> { |
| | | boolean isMaxSize = result.size() == mAdapter.getSelectMax(); |
| | | int oldSize = mAdapter.getData().size(); |
| | | mAdapter.notifyItemRangeRemoved(0, isMaxSize ? oldSize + 1 : oldSize); |
| | | mAdapter.getData().clear(); |
| | | |
| | | mAdapter.getData().addAll(result); |
| | | mAdapter.notifyItemRangeInserted(0, result.size()); |
| | | mAdapter.getData().addAll(result); |
| | | mAdapter.notifyItemRangeInserted(0, result.size()); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |