用户数据同步相关

This commit is contained in:
kehaoyuan
2017-09-14 20:03:47 +08:00
parent acec42c6af
commit 235a13855b
14 changed files with 310 additions and 251 deletions

View File

@ -3,6 +3,7 @@ package com.gh.common.util;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
@ -15,10 +16,13 @@ import com.gh.gamecenter.CommentDetailActivity;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.OnCommentCallBackListener;
import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
import com.gh.gamecenter.db.CommentDao;
import com.gh.gamecenter.db.VoteDao;
import com.gh.gamecenter.db.info.VoteInfo;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.entity.UserDataEntity;
import com.gh.gamecenter.entity.UserInfoEntity;
import com.lightgame.utils.Utils;
import org.json.JSONException;
@ -208,7 +212,7 @@ public class CommentUtils {
reportTypeDialog.show();
}
public static void initVote(final Context context, final CommentEntity commentEntity, final VoteDao voteDao,
public static void postVote(final Context context, final CommentEntity commentEntity, final VoteDao voteDao,
final TextView commentLikeCountTv, final ImageView commentLikeIv, final OnVoteListener listener) {
CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() {
@Override
@ -267,6 +271,39 @@ public class CommentUtils {
});
}
// 设置评论item 用户相关的view(点赞/头像/用户名)
public static void setCommentUserView(Context mContext, CommentViewHolder holder, CommentEntity entity) {
UserDataEntity userDataEntity = entity.getUserData();
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.hint));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
if (entity.getVote() == 0) {
holder.commentLikeCountTv.setVisibility(View.GONE);
} else { // 检查是否已点赞
if (userDataEntity != null && userDataEntity.isCommentVoted()) {
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
}
holder.commentLikeCountTv.setVisibility(View.VISIBLE);
holder.commentLikeCountTv.setText(String.valueOf(entity.getVote()));
}
//检查是否是自身评论
UserInfoEntity userInfo = LoginUtils.getUserInfo(mContext);
if (userDataEntity != null && userDataEntity.isCommentOwn() && userInfo != null) {
holder.commentUserNameTv.setText(userInfo.getName());
ImageUtils.Companion.display(holder.commentUserIconDv, userInfo.getIcon());
} else {
holder.commentUserNameTv.setText(entity.getUser().getName());
if (TextUtils.isEmpty(entity.getUser().getIcon())) {
holder.commentUserIconDv.setImageURI(Uri.parse("res:///" + R.drawable.user_default_icon_comment));
} else {
ImageUtils.Companion.display(holder.commentUserIconDv, entity.getUser().getIcon());
}
}
}
public interface OnVoteListener {
void onVote();
}