Merge branch '3.0' of gitlab.ghzhushou.com:halo/assistant-android into 3.0

# Conflicts:
#	app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java
#	app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java
#	app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java
This commit is contained in:
CsHeng
2017-06-29 11:23:47 +08:00
17 changed files with 547 additions and 495 deletions

View File

@ -1,5 +1,6 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
@ -13,6 +14,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.gh.common.constant.Config;
import com.gh.common.util.CommentUtils;
import com.gh.common.util.ConcernContentUtils;
@ -22,10 +24,8 @@ import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.NewsUtils;
import com.gh.common.util.PostCommentUtils;
import com.gh.common.util.StringUtils;
import com.gh.common.util.TimestampUtils;
import com.lightgame.utils.Utils;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
@ -37,7 +37,6 @@ import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsDigestViewHolder;
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.ConcernEntity;
import com.gh.gamecenter.manager.VisitManager;
@ -437,22 +436,10 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
holder.commentLikeIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (holder.commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(mContext, R.color.theme)) {
Utils.toast(mContext, "已经点过赞啦!");
return;
}
finalCommentEntity.setVote(finalCommentEntity.getVote() + 1);
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
holder.commentLikeCountTv.setText(String.valueOf(finalCommentEntity.getVote()));
holder.commentLikeCountTv.setVisibility(View.VISIBLE);
PostCommentUtils.addCommentVoto(mContext, finalCommentEntity.getId(), true,
new PostCommentUtils.PostCommentListener() {
CommentUtils.initVote(mContext, finalCommentEntity, mVoteDao, holder.commentLikeCountTv,
holder.commentLikeIv, new CommentUtils.OnVoteListener() {
@Override
public void postSuccess(JSONObject response) {
mVoteDao.add(new VoteInfo(finalCommentEntity.getId()));
public void onVote() {
int index = (finalCommentPosition / 10) * 10;
//获取需要修改缓存的链接
@ -467,35 +454,6 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
modifyVolleyCache(finalCommentEntity.getId(), cacheUrl); //修改缓存
}
@Override
public void postFailed(Throwable e) {
finalCommentEntity.setVote(finalCommentEntity.getVote() - 1);
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.hint));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
holder.commentLikeCountTv.setText(String.valueOf(finalCommentEntity.getVote()));
if (finalCommentEntity.getVote() == 0) {
holder.commentLikeCountTv.setVisibility(View.GONE);
} else {
holder.commentLikeCountTv.setVisibility(View.VISIBLE);
}
if (e instanceof HttpException) {
HttpException exception = (HttpException) e;
if (exception.code() == 403) {
try {
if (new JSONObject(exception.response().errorBody().string()).getString("detail").equals("voted")) {
Utils.toast(mContext, "已经点过赞啦!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
return;
}
}
Utils.toast(mContext, "网络异常,点赞失败");
}
});
}