Search in sources :

Example 1 with BlockedBlogResult

use of org.wordpress.android.ui.reader.actions.ReaderBlogActions.BlockedBlogResult in project WordPress-Android by wordpress-mobile.

the class ReaderPostListFragment method blockBlogForPost.

/*
     * blocks the blog associated with the passed post and removes all posts in that blog
     * from the adapter
     */
private void blockBlogForPost(final ReaderPost post) {
    if (post == null || !isAdded() || !hasPostAdapter() || !NetworkUtils.checkConnection(getActivity())) {
        return;
    }
    ReaderActions.ActionListener actionListener = new ReaderActions.ActionListener() {

        @Override
        public void onActionResult(boolean succeeded) {
            if (!succeeded && isAdded()) {
                ToastUtils.showToast(getActivity(), R.string.reader_toast_err_block_blog, ToastUtils.Duration.LONG);
            }
        }
    };
    // perform call to block this blog - returns list of posts deleted by blocking so
    // they can be restored if the user undoes the block
    final BlockedBlogResult blockResult = ReaderBlogActions.blockBlogFromReader(post.blogId, actionListener);
    // Only pass the blogID if available. Do not track feedID
    AnalyticsUtils.trackWithSiteId(AnalyticsTracker.Stat.READER_BLOG_BLOCKED, mCurrentBlogId);
    // remove posts in this blog from the adapter
    getPostAdapter().removePostsInBlog(post.blogId);
    // show the undo snackbar enabling the user to undo the block
    View.OnClickListener undoListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ReaderBlogActions.undoBlockBlogFromReader(blockResult);
            refreshPosts();
        }
    };
    Snackbar.make(getView(), getString(R.string.reader_toast_blog_blocked), Snackbar.LENGTH_LONG).setAction(R.string.undo, undoListener).show();
}
Also used : BlockedBlogResult(org.wordpress.android.ui.reader.actions.ReaderBlogActions.BlockedBlogResult) SearchView(android.support.v7.widget.SearchView) ReaderSiteHeaderView(org.wordpress.android.ui.reader.views.ReaderSiteHeaderView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) FilteredRecyclerView(org.wordpress.android.ui.FilteredRecyclerView) AutoCompleteTextView(android.widget.AutoCompleteTextView) RecyclerView(android.support.v7.widget.RecyclerView) ReaderActions(org.wordpress.android.ui.reader.actions.ReaderActions)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 SearchView (android.support.v7.widget.SearchView)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FilteredRecyclerView (org.wordpress.android.ui.FilteredRecyclerView)1 ReaderActions (org.wordpress.android.ui.reader.actions.ReaderActions)1 BlockedBlogResult (org.wordpress.android.ui.reader.actions.ReaderBlogActions.BlockedBlogResult)1 ReaderSiteHeaderView (org.wordpress.android.ui.reader.views.ReaderSiteHeaderView)1