use of com.yydcdut.note.bus.CategoryDeleteEvent in project PhotoNoter by yydcdut.
the class HomePresenterImpl method onCategoryDeleteEvent.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onCategoryDeleteEvent(CategoryDeleteEvent categoryDeleteEvent) {
mRxCategory.getAllCategories().observeOn(AndroidSchedulers.mainThread()).subscribe(categories -> {
int beforeCategoryId = mCategoryId;
for (Category category : categories) {
if (category.isCheck()) {
mCategoryId = category.getId();
break;
}
}
mHomeView.updateCategoryList(categories);
if (mCategoryId != beforeCategoryId) {
mHomeView.changePhotos4Category(mCategoryId);
}
}, (throwable -> YLog.e(throwable)));
}
use of com.yydcdut.note.bus.CategoryDeleteEvent in project PhotoNoter by yydcdut.
the class EditCategoryPresenterImpl method handleMessage.
@Override
public boolean handleMessage(Message msg) {
switch(msg.what) {
case MESSAGE_RENAME_NONE:
deleteCategories();
return false;
case MESSAGE_DELETE_NONE:
sortCategories();
return false;
case MESSAGE_FINISH:
if (mDeleteCategoryIdList.size() > 0) {
EventBus.getDefault().post(new CategoryDeleteEvent());
} else {
EventBus.getDefault().post(new CategoryEditEvent());
}
mEditCategoryView.hideProgressBar();
mEditCategoryView.finishActivity();
return false;
default:
mCurrentMessage++;
break;
}
if (mCurrentMessage == mRenameCategoryLabelMap.size()) {
deleteCategories();
} else if (mCurrentMessage == mRenameCategoryLabelMap.size() + mDeleteCategoryIdList.size()) {
sortCategories();
} else if (mCurrentMessage == mRenameCategoryLabelMap.size() + mDeleteCategoryIdList.size() + 1) {
mRxCategory.getAllCategories().subscribe((categories -> {
// todo 删除图片,删除PhotoNote
boolean checked = false;
for (Category category : categories) {
checked |= category.isCheck();
}
if (!checked && categories.size() > 0) {
categories.get(0).setCheck(true);
mRxCategory.updateCategory(categories.get(0)).subscribe();
}
// todo 当所有的都没有了怎么办
}), (throwable -> YLog.e(throwable)), () -> mHandler.sendEmptyMessage(MESSAGE_FINISH));
}
return false;
}
Aggregations