use of com.yydcdut.note.bus.CategoryEditEvent 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 -> {
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();
}
}), (throwable -> YLog.e(throwable)), () -> mHandler.sendEmptyMessage(MESSAGE_FINISH));
}
return false;
}
Aggregations