use of com.yydcdut.note.bus.CategoryMoveEvent in project PhotoNoter by yydcdut.
the class AlbumPresenterImpl method changePhotosCategory.
@Override
public void changePhotosCategory(int toCategoryId) {
if (mCategoryId != toCategoryId) {
mRxPhotoNote.findByCategoryId(mCategoryId, mAlbumSortKind).observeOn(AndroidSchedulers.mainThread()).map(photoNoteList -> {
TreeMap<Integer, PhotoNote> map = getTreeMap();
for (int i = 0; i < photoNoteList.size(); i++) {
PhotoNote photoNote = photoNoteList.get(i);
if (photoNote.isSelected()) {
photoNote.setSelected(false);
photoNote.setCategoryId(toCategoryId);
map.put(i, photoNote);
}
}
int times = 0;
for (Map.Entry<Integer, PhotoNote> entry : map.entrySet()) {
photoNoteList.remove(entry.getValue());
mAlbumView.notifyItemRemoved(entry.getKey() - times);
mRxPhotoNote.updatePhotoNote(entry.getValue()).subscribe((photoNotes -> {
}), (throwable -> YLog.e(throwable)));
times++;
}
return map.size();
}).subscribe(integer -> {
mRxCategory.updateChangeCategory(mCategoryId, toCategoryId, integer).subscribe(categories -> {
mRxPhotoNote.refreshByCategoryId(mCategoryId, ComparatorFactory.FACTORY_NOT_SORT).subscribe((photoNoteList) -> mAlbumView.updateDataNoChange(photoNoteList), (throwable -> YLog.e(throwable)));
mRxPhotoNote.refreshByCategoryId(toCategoryId, ComparatorFactory.FACTORY_NOT_SORT).subscribe(photoNotes -> {
}, (throwable -> YLog.e(throwable)));
EventBus.getDefault().post(new CategoryMoveEvent());
}, (throwable -> YLog.e(throwable)));
}, (throwable -> YLog.e(throwable)));
}
}
Aggregations