use of com.yydcdut.note.bus.PhotoNoteDeleteEvent in project PhotoNoter by yydcdut.
the class AlbumPresenterImpl method deletePhotos.
@Override
public void deletePhotos() {
//注意java.util.ConcurrentModificationException at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
mRxPhotoNote.findByCategoryId(mCategoryId, mAlbumSortKind).observeOn(AndroidSchedulers.mainThread()).subscribe(photoNoteList -> {
TreeMap<Integer, PhotoNote> map = getTreeMap();
for (int i = 0; i < photoNoteList.size(); i++) {
PhotoNote photoNote = photoNoteList.get(i);
if (photoNote.isSelected()) {
map.put(i, photoNote);
}
}
int times = 0;
for (Map.Entry<Integer, PhotoNote> entry : map.entrySet()) {
photoNoteList.remove(entry.getValue());
mAlbumView.notifyItemRemoved(entry.getKey() - times);
times++;
mRxPhotoNote.deletePhotoNote(entry.getValue()).subscribe(photoNotes -> {
FilePathUtils.deleteAllFiles(entry.getValue().getPhotoName());
mAlbumView.updateDataNoChange(photoNoteList);
}, (throwable -> YLog.e(throwable)));
}
EventBus.getDefault().post(new PhotoNoteDeleteEvent());
}, (throwable -> YLog.e(throwable)));
}
Aggregations