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();
}
Aggregations