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