Search in sources :

Example 1 with ReaderIconCountView

use of org.wordpress.android.ui.reader.views.ReaderIconCountView in project WordPress-Android by wordpress-mobile.

the class ReaderPostDetailFragment method refreshIconCounts.

private void refreshIconCounts() {
    if (!isAdded() || !hasPost() || !canShowFooter()) {
        return;
    }
    final ReaderIconCountView countLikes = (ReaderIconCountView) getView().findViewById(R.id.count_likes);
    final ReaderIconCountView countComments = (ReaderIconCountView) getView().findViewById(R.id.count_comments);
    if (canShowCommentCount()) {
        countComments.setCount(mPost.numReplies);
        countComments.setVisibility(View.VISIBLE);
        countComments.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ReaderActivityLauncher.showReaderComments(getActivity(), mPost.blogId, mPost.postId);
            }
        });
    } else {
        countComments.setVisibility(View.INVISIBLE);
        countComments.setOnClickListener(null);
    }
    if (canShowLikeCount()) {
        countLikes.setCount(mPost.numLikes);
        countLikes.setVisibility(View.VISIBLE);
        countLikes.setSelected(mPost.isLikedByCurrentUser);
        if (!mAccountStore.hasAccessToken()) {
            countLikes.setEnabled(false);
        } else if (mPost.canLikePost()) {
            countLikes.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    togglePostLike();
                }
            });
        }
        // views to take up space right now
        if (mPost.numLikes > 0 && mLikingUsersView.getVisibility() == View.GONE) {
            mLikingUsersView.setVisibility(View.INVISIBLE);
            mLikingUsersDivider.setVisibility(View.INVISIBLE);
            mLikingUsersLabel.setVisibility(View.INVISIBLE);
        }
    } else {
        countLikes.setVisibility(View.INVISIBLE);
        countLikes.setOnClickListener(null);
    }
}
Also used : ReaderIconCountView(org.wordpress.android.ui.reader.views.ReaderIconCountView) ReaderSimplePostContainerView(org.wordpress.android.ui.reader.views.ReaderSimplePostContainerView) ReaderSimplePostView(org.wordpress.android.ui.reader.views.ReaderSimplePostView) ReaderWebView(org.wordpress.android.ui.reader.views.ReaderWebView) View(android.view.View) WebView(android.webkit.WebView) WPScrollView(org.wordpress.android.widgets.WPScrollView) ReaderPostDetailHeaderView(org.wordpress.android.ui.reader.views.ReaderPostDetailHeaderView) TextView(android.widget.TextView) WPTextView(org.wordpress.android.widgets.WPTextView) ReaderIconCountView(org.wordpress.android.ui.reader.views.ReaderIconCountView) ReaderLikingUsersView(org.wordpress.android.ui.reader.views.ReaderLikingUsersView)

Example 2 with ReaderIconCountView

use of org.wordpress.android.ui.reader.views.ReaderIconCountView in project WordPress-Android by wordpress-mobile.

the class ReaderPostDetailFragment method setPostLike.

/*
     * changes the like on the passed post
     */
private void setPostLike(boolean isAskingToLike) {
    if (!isAdded() || !hasPost() || !NetworkUtils.checkConnection(getActivity())) {
        return;
    }
    if (isAskingToLike != ReaderPostTable.isPostLikedByCurrentUser(mPost)) {
        ReaderIconCountView likeCount = (ReaderIconCountView) getView().findViewById(R.id.count_likes);
        likeCount.setSelected(isAskingToLike);
        ReaderAnim.animateLikeButton(likeCount.getImageView(), isAskingToLike);
        boolean success = ReaderPostActions.performLikeAction(mPost, isAskingToLike, mAccountStore.getAccount().getUserId());
        if (!success) {
            likeCount.setSelected(!isAskingToLike);
            return;
        }
        // get the post again since it has changed, then refresh to show changes
        mPost = ReaderPostTable.getBlogPost(mPost.blogId, mPost.postId, false);
        refreshLikes();
        refreshIconCounts();
    }
    if (isAskingToLike) {
        AnalyticsUtils.trackWithReaderPostDetails(AnalyticsTracker.Stat.READER_ARTICLE_LIKED, mPost);
    } else {
        AnalyticsUtils.trackWithReaderPostDetails(AnalyticsTracker.Stat.READER_ARTICLE_UNLIKED, mPost);
    }
}
Also used : ReaderIconCountView(org.wordpress.android.ui.reader.views.ReaderIconCountView)

Aggregations

ReaderIconCountView (org.wordpress.android.ui.reader.views.ReaderIconCountView)2 View (android.view.View)1 WebView (android.webkit.WebView)1 TextView (android.widget.TextView)1 ReaderLikingUsersView (org.wordpress.android.ui.reader.views.ReaderLikingUsersView)1 ReaderPostDetailHeaderView (org.wordpress.android.ui.reader.views.ReaderPostDetailHeaderView)1 ReaderSimplePostContainerView (org.wordpress.android.ui.reader.views.ReaderSimplePostContainerView)1 ReaderSimplePostView (org.wordpress.android.ui.reader.views.ReaderSimplePostView)1 ReaderWebView (org.wordpress.android.ui.reader.views.ReaderWebView)1 WPScrollView (org.wordpress.android.widgets.WPScrollView)1 WPTextView (org.wordpress.android.widgets.WPTextView)1