use of com.yydcdut.note.entity.Category 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;
}
use of com.yydcdut.note.entity.Category in project PhotoNoter by yydcdut.
the class CheckService method checkCategoryPhotoNumber.
/**
* 判断category中的photoNumber是否正确
*/
private void checkCategoryPhotoNumber() {
mRxCategory.getAllCategories().subscribe(categories -> {
for (Category category : categories) {
mRxPhotoNote.findByCategoryId(category.getId(), ComparatorFactory.FACTORY_NOT_SORT).subscribe(photoNoteList1 -> {
if (category.getPhotosNumber() != photoNoteList1.size()) {
category.setPhotosNumber(photoNoteList1.size());
mRxCategory.updateCategory(category).subscribe();
}
}, (throwable -> YLog.e(throwable)));
}
});
}
use of com.yydcdut.note.entity.Category in project PhotoNoter by yydcdut.
the class AlbumFragment method showAddCategoryDialog.
/**
* 添加category的dialog
*/
private void showAddCategoryDialog() {
View v = LayoutInflater.from(getContext()).inflate(R.layout.dialog_edittext, null);
final EditText editText = (EditText) v.findViewById(R.id.edit_dialog);
new AlertDialog.Builder(getContext(), R.style.note_dialog).setTitle(R.string.dialog_title_new).setCancelable(false).setView(v).setPositiveButton(R.string.dialog_btn_ok, (dialog, which) -> mAlbumPresenter.createCategory(editText.getText().toString())).setNegativeButton(R.string.dialog_btn_cancel, (dialog, which) -> dialog.dismiss()).show();
}
use of com.yydcdut.note.entity.Category in project PhotoNoter by yydcdut.
the class CategoryDBTest method testUpdateCategory.
public void testUpdateCategory() {
CategoryDB categoryDB = new CategoryDB(this.getInstrumentation().getTargetContext());
List<Category> categoryList = categoryDB.findAll();
Category category = categoryList.get(0);
category.setLabel("789456");
mRxCategory.updateCategory(category).subscribe(new Subscriber<List<Category>>() {
@Override
public void onCompleted() {
YLog.i("yuyidong", "onCompleted");
}
@Override
public void onError(Throwable e) {
YLog.i("yuyidong", "onError,,,e--->" + e.getMessage());
}
@Override
public void onNext(List<Category> categories) {
YLog.i("yuyidong", "categories.size()--->" + categories.size());
for (Category category : categories) {
YLog.i("yuyidong", category.toString());
}
}
});
}
Aggregations