Search in sources :

Example 1 with PostError

use of org.wordpress.android.fluxc.store.PostStore.PostError in project WordPress-Android by wordpress-mobile.

the class PostsListFragment method onPostChanged.

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPostChanged(OnPostChanged event) {
    switch(event.causeOfChange) {
        case FETCH_POSTS:
        case FETCH_PAGES:
            mIsFetchingPosts = false;
            if (!isAdded()) {
                return;
            }
            setRefreshing(false);
            hideLoadMoreProgress();
            if (!event.isError()) {
                mCanLoadMorePosts = event.canLoadMore;
                loadPosts(LoadMode.IF_CHANGED);
            } else {
                PostError error = event.error;
                switch(error.type) {
                    case UNAUTHORIZED:
                        updateEmptyView(EmptyViewMessageType.PERMISSION_ERROR);
                        break;
                    default:
                        updateEmptyView(EmptyViewMessageType.GENERIC_ERROR);
                        break;
                }
            }
            break;
        case DELETE_POST:
            if (event.isError()) {
                String message = String.format(getText(R.string.error_delete_post).toString(), mIsPage ? "page" : "post");
                ToastUtils.showToast(getActivity(), message, ToastUtils.Duration.SHORT);
                loadPosts(LoadMode.IF_CHANGED);
            }
            break;
    }
}
Also used : PostError(org.wordpress.android.fluxc.store.PostStore.PostError) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

Subscribe (org.greenrobot.eventbus.Subscribe)1 PostError (org.wordpress.android.fluxc.store.PostStore.PostError)1