Search in sources :

Example 1 with CategoryCreateEvent

use of com.yydcdut.note.bus.CategoryCreateEvent in project PhotoNoter by yydcdut.

the class AlbumPresenterImpl method createCategory.

@Override
public void createCategory(String newCategoryLabel) {
    mRxCategory.getAllCategories().observeOn(AndroidSchedulers.mainThread()).subscribe(categories -> {
        int totalNumber = categories.size();
        if (!TextUtils.isEmpty(newCategoryLabel)) {
            mRxCategory.saveCategory(newCategoryLabel, 0, totalNumber, true).observeOn(AndroidSchedulers.mainThread()).subscribe(categories1 -> {
                boolean success = false;
                for (Category category : categories1) {
                    if (category.getLabel().equals(newCategoryLabel)) {
                        mAlbumView.changeActivityListMenuCategoryChecked(category);
                        EventBus.getDefault().post(new CategoryCreateEvent());
                        success = true;
                        break;
                    }
                }
                if (!success) {
                    mAlbumView.showToast(mContext.getResources().getString(R.string.toast_fail));
                }
            }, (throwable -> YLog.e(throwable)));
        } else {
            mAlbumView.showToast(mContext.getResources().getString(R.string.toast_fail));
        }
    }, (throwable -> YLog.e(throwable)));
}
Also used : Context(android.content.Context) RxPhotoNote(com.yydcdut.note.model.rx.RxPhotoNote) Uri(android.net.Uri) PhotoNoteDeleteEvent(com.yydcdut.note.bus.PhotoNoteDeleteEvent) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) ArrayList(java.util.ArrayList) Observable(rx.Observable) Inject(javax.inject.Inject) IAlbumView(com.yydcdut.note.views.home.IAlbumView) ContentResolver(android.content.ContentResolver) RxSandBox(com.yydcdut.note.model.rx.RxSandBox) Handler(android.os.Handler) ContextLife(com.yydcdut.note.injector.ContextLife) EventBus(org.greenrobot.eventbus.EventBus) Map(java.util.Map) Category(com.yydcdut.note.entity.Category) FilePathUtils(com.yydcdut.note.utils.FilePathUtils) R(com.yydcdut.note.R) Utils(com.yydcdut.note.utils.Utils) PermissionUtils(com.yydcdut.note.utils.PermissionUtils) Fragment(android.app.Fragment) RxCategory(com.yydcdut.note.model.rx.RxCategory) CategoryMoveEvent(com.yydcdut.note.bus.CategoryMoveEvent) Subscriber(rx.Subscriber) PhotoNoteCreateEvent(com.yydcdut.note.bus.PhotoNoteCreateEvent) LocalStorageUtils(com.yydcdut.note.utils.LocalStorageUtils) TextUtils(android.text.TextUtils) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) IAlbumPresenter(com.yydcdut.note.presenters.home.IAlbumPresenter) List(java.util.List) Permission(com.yydcdut.note.utils.permission.Permission) TreeMap(java.util.TreeMap) ComparatorFactory(com.yydcdut.note.model.compare.ComparatorFactory) ImageLoaderManager(com.yydcdut.note.utils.ImageManager.ImageLoaderManager) CategoryCreateEvent(com.yydcdut.note.bus.CategoryCreateEvent) PhotoNote(com.yydcdut.note.entity.PhotoNote) Comparator(java.util.Comparator) YLog(com.yydcdut.note.utils.YLog) IView(com.yydcdut.note.views.IView) Category(com.yydcdut.note.entity.Category) RxCategory(com.yydcdut.note.model.rx.RxCategory) CategoryCreateEvent(com.yydcdut.note.bus.CategoryCreateEvent)

Aggregations

Fragment (android.app.Fragment)1 ContentResolver (android.content.ContentResolver)1 Context (android.content.Context)1 Uri (android.net.Uri)1 Handler (android.os.Handler)1 TextUtils (android.text.TextUtils)1 R (com.yydcdut.note.R)1 CategoryCreateEvent (com.yydcdut.note.bus.CategoryCreateEvent)1 CategoryMoveEvent (com.yydcdut.note.bus.CategoryMoveEvent)1 PhotoNoteCreateEvent (com.yydcdut.note.bus.PhotoNoteCreateEvent)1 PhotoNoteDeleteEvent (com.yydcdut.note.bus.PhotoNoteDeleteEvent)1 Category (com.yydcdut.note.entity.Category)1 PhotoNote (com.yydcdut.note.entity.PhotoNote)1 ContextLife (com.yydcdut.note.injector.ContextLife)1 ComparatorFactory (com.yydcdut.note.model.compare.ComparatorFactory)1 RxCategory (com.yydcdut.note.model.rx.RxCategory)1 RxPhotoNote (com.yydcdut.note.model.rx.RxPhotoNote)1 RxSandBox (com.yydcdut.note.model.rx.RxSandBox)1 IAlbumPresenter (com.yydcdut.note.presenters.home.IAlbumPresenter)1 FilePathUtils (com.yydcdut.note.utils.FilePathUtils)1