diff --git a/app/src/main/java/com/gh/common/util/CommentHelper.kt b/app/src/main/java/com/gh/common/util/CommentHelper.kt index d47c9ecdfb..8ad268ba3b 100644 --- a/app/src/main/java/com/gh/common/util/CommentHelper.kt +++ b/app/src/main/java/com/gh/common/util/CommentHelper.kt @@ -72,11 +72,6 @@ object CommentHelper { videoId: String? = null, listener: OnCommentCallBackListener? = null) { val dialogOptions = ArrayList() - - if (commentEntity.me == null || !commentEntity.me?.isCommentOwner!!) { - dialogOptions.add("回复") - } - dialogOptions.add("复制") dialogOptions.add("投诉") @@ -97,18 +92,6 @@ object CommentHelper { when (it) { "管理" -> showControlDialog(context, answerId, articleId, communityId, commentEntity, commentEntity.me!!) - "回复" -> { - context.ifLogin("回答详情-评论-回复") { - if (listener != null) { - listener.onCommentCallback(commentEntity) - } else if (!TextUtils.isEmpty(commentEntity.id)) { - context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, commentEntity.id)) - } else { - Utils.toast(context, "缺少关键属性") - } - } - } - "复制" -> copyText(commentEntity.content, context) "投诉" -> { diff --git a/app/src/main/java/com/gh/common/util/CommentUtils.java b/app/src/main/java/com/gh/common/util/CommentUtils.java index 947fa0cba8..9f241c264e 100644 --- a/app/src/main/java/com/gh/common/util/CommentUtils.java +++ b/app/src/main/java/com/gh/common/util/CommentUtils.java @@ -13,9 +13,7 @@ import android.widget.LinearLayout; import android.widget.TextView; 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.entity.CommentEntity; import com.gh.gamecenter.entity.MeEntity; @@ -85,8 +83,6 @@ public class CommentUtils { public static void showReportDialog(final CommentEntity commentEntity, final Context context, final boolean showConversation, - final OnCommentCallBackListener listener, - final String newsId, final String patch) { final Dialog dialog = new Dialog(context); @@ -96,11 +92,6 @@ public class CommentUtils { container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12)); List dialogType = new ArrayList<>(); - - if (commentEntity.getMe() == null || !commentEntity.getMe().isCommentOwner()) { - dialogType.add("回复"); - } - dialogType.add("复制"); dialogType.add("投诉"); @@ -126,17 +117,6 @@ public class CommentUtils { public void onClick(View v) { dialog.cancel(); switch (reportTv.getText().toString()) { - case "回复": - CheckLoginUtils.checkLogin(context, patch + "-回复", () -> { - if (listener != null) { - listener.onCommentCallback(commentEntity); - } else if (!TextUtils.isEmpty(newsId)) { - context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, newsId)); - } else { - Utils.toast(context, "缺少关键属性"); - } - }); - break; case "复制": copyText(commentEntity.getContent(), context); break; @@ -224,7 +204,7 @@ public class CommentUtils { } commentEntity.setVote(commentEntity.getVote() + 1); commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme)); - commentLikeIv.setImageResource(R.drawable.vote_icon_select); + commentLikeIv.setImageResource(R.drawable.comment_vote_select); commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote())); commentLikeCountTv.setVisibility(View.VISIBLE); @@ -242,7 +222,7 @@ public class CommentUtils { commentEntity.setVote(commentEntity.getVote() - 1); commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint)); - commentLikeIv.setImageResource(R.drawable.vote_icon_unselect); + commentLikeIv.setImageResource(R.drawable.comment_vote_unselect); commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote())); if (commentEntity.getVote() == 0) { commentLikeCountTv.setVisibility(View.GONE); @@ -290,7 +270,7 @@ public class CommentUtils { } commentEntity.setVote(commentEntity.getVote() + 1); commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme)); - commentLikeIv.setImageResource(R.drawable.vote_icon_select); + commentLikeIv.setImageResource(R.drawable.comment_vote_select); commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote())); commentLikeCountTv.setVisibility(View.VISIBLE); @@ -307,7 +287,7 @@ public class CommentUtils { public void postFailed(Throwable e) { commentEntity.setVote(commentEntity.getVote() - 1); commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint)); - commentLikeIv.setImageResource(R.drawable.vote_icon_unselect); + commentLikeIv.setImageResource(R.drawable.comment_vote_unselect); commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote())); if (commentEntity.getVote() == 0) { commentLikeCountTv.setVisibility(View.GONE); @@ -340,14 +320,22 @@ public class CommentUtils { public static void setCommentUserView(Context mContext, CommentViewHolder holder, CommentEntity entity) { MeEntity userDataEntity = entity.getMe(); holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.hint)); - holder.commentLikeIv.setImageResource(R.drawable.vote_icon_unselect); + holder.commentLikeIv.setImageResource(R.drawable.comment_vote_unselect); + + if (userDataEntity == null || !userDataEntity.isCommentOwner()) { + holder.replyLine.setVisibility(View.VISIBLE); + holder.commentReply.setVisibility(View.VISIBLE); + } else { + holder.replyLine.setVisibility(View.GONE); + holder.commentReply.setVisibility(View.GONE); + } 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.vote_icon_select); + holder.commentLikeIv.setImageResource(R.drawable.comment_vote_select); } holder.commentLikeCountTv.setVisibility(View.VISIBLE); holder.commentLikeCountTv.setText(NumberUtils.transSimpleCount(entity.getVote())); diff --git a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java index 67b5252d15..514173086a 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java @@ -12,6 +12,7 @@ import com.gh.common.util.DirectUtils; import com.gh.common.util.ImageUtils; import com.gh.common.util.MtaHelper; import com.gh.common.util.TextHelper; +import com.gh.gamecenter.MessageDetailActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.adapter.viewholder.CommentViewHolder; import com.gh.gamecenter.adapter.viewholder.FooterViewHolder; @@ -149,13 +150,10 @@ public class CommentDetailAdapter extends BaseRecyclerAdapter { private void initCommentViewHolder(final CommentViewHolder holder, int position) { final CommentEntity commentEntity = mCommentList.get(position); - holder.commentLine.setVisibility(View.VISIBLE); - holder.commentLineBottom.setVisibility(View.GONE); - CommentUtils.setCommentUserView(mContext, holder, commentEntity); CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.getTime()); - + TextHelper.highlightTextThatIsWrappedInsideWrapperByDefault(holder.commentContentTv, commentEntity.getContent()); ArticleCommentParent parent = commentEntity.getParent(); if (parent != null && !TextUtils.isEmpty(parent.getUser().getName())) { @@ -186,10 +184,18 @@ public class CommentDetailAdapter extends BaseRecyclerAdapter { commentEntity, holder.commentLikeCountTv, holder.commentLikeIv, null))); - holder.itemView.setOnClickListener(v -> + holder.commentReply.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CheckLoginUtils.checkLogin(mContext, "资讯文章-评论-回复", () -> { + mOnCommentCallBackListener.onCommentCallback(commentEntity); + }); + } + }); + + holder.commentMore.setOnClickListener(v -> CommentUtils.showReportDialog(commentEntity, - mContext, false, - mOnCommentCallBackListener, null, "资讯文章-评论")); + mContext, false, "资讯文章-评论")); holder.commentUserIconDv.setOnClickListener(v -> DirectUtils.directToHomeActivity(mContext, commentEntity.getUser().getId(), "", "文章-评论详情")); holder.commentUserNameTv.setOnClickListener(v -> DirectUtils.directToHomeActivity(mContext, commentEntity.getUser().getId(), "", "文章-评论详情")); diff --git a/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java index 75d05ceaac..e019ef9a47 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java @@ -24,6 +24,7 @@ import com.gh.common.util.NumberUtils; import com.gh.common.util.StringUtils; import com.gh.common.util.TextHelper; import com.gh.common.util.TimestampUtils; +import com.gh.gamecenter.MessageDetailActivity; import com.gh.gamecenter.NewsDetailActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.ShareCardActivity; @@ -410,10 +411,18 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter { }) )); - holder.itemView.setOnClickListener(v -> + holder.commentReply.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CheckLoginUtils.checkLogin(mContext, "资讯文章详情-评论详情-回复", () -> { + mOnCommentCallBackListener.onCommentCallback(finalCommentEntity); + }); + } + }); + + holder.commentMore.setOnClickListener(v -> CommentUtils.showReportDialog(finalCommentEntity, - mContext, true, - mOnCommentCallBackListener, null, "资讯文章详情-评论详情")); + mContext, true, "资讯文章详情-评论详情")); holder.commentUserNameTv.setOnClickListener(v -> DirectUtils.directToHomeActivity(mContext, finalCommentEntity.getUser().getId(), mEntrance, "文章-评论详情")); holder.commentUserIconDv.setOnClickListener(v -> DirectUtils.directToHomeActivity(mContext, finalCommentEntity.getUser().getId(), mEntrance, "文章-评论详情")); diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/CommentViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/CommentViewHolder.java index 4f482485ba..28450cf62c 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/CommentViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/CommentViewHolder.java @@ -16,8 +16,6 @@ import butterknife.BindView; */ public class CommentViewHolder extends BaseRecyclerViewHolder { - @BindView(R.id.comment_line) - public View commentLine; @BindView(R.id.comment_content) public TextView commentContentTv; @BindView(R.id.comment_like) @@ -34,8 +32,6 @@ public class CommentViewHolder extends BaseRecyclerViewHolder { public TextView commentUserNameTv; @BindView(R.id.comment_author) public TextView commentAuthorTv; - @BindView(R.id.comment_line_bottom) - public View commentLineBottom; @BindView(R.id.comment_badge) public View commentBadge; @@ -52,6 +48,12 @@ public class CommentViewHolder extends BaseRecyclerViewHolder { public TextView badgeNameTv; @BindView(R.id.sdv_quote_author_badge) public SimpleDraweeView quoteAuthorBadgeSdv; + @BindView(R.id.comment_more) + public View commentMore; + @BindView(R.id.comment_reply) + public View commentReply; + @BindView(R.id.reply_dividing_line) + public View replyLine; public CommentViewHolder(View itemView) { super(itemView); diff --git a/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java index 247ca3dde9..8c4bd7ea7d 100644 --- a/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java @@ -601,10 +601,19 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { () -> CommentUtils.postVote(mContext, commentEntity, viewHolder.commentLikeCountTv, viewHolder.commentLikeIv, null))); - contentView.setOnClickListener(v -> + + // 资讯文章详情回复 直接跳转至评论详情 + viewHolder.commentReply.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CheckLoginUtils.checkLogin(mContext, "资讯文章详情-评论-回复", () -> { + mContext.startActivity(MessageDetailActivity.getMessageDetailIntent(mContext, commentEntity, mNewsDetailEntity.getId())); + }); + } + }); + viewHolder.commentMore.setOnClickListener(v -> CommentUtils.showReportDialog(commentEntity, - mContext, true, null, - mNewsDetailEntity.getId(), "资讯文章详情-评论")); + mContext, true, "资讯文章详情-评论")); viewHolder.commentUserNameTv.setOnClickListener(v -> DirectUtils.directToHomeActivity(mContext, commentEntity.getUser().getId(), mEntrance, "文章-评论列表")); viewHolder.commentUserIconDv.setOnClickListener(v -> DirectUtils.directToHomeActivity(mContext, commentEntity.getUser().getId(), mEntrance, "文章-评论列表")); diff --git a/app/src/main/java/com/gh/gamecenter/qa/answer/CommunityAnswerItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/qa/answer/CommunityAnswerItemViewHolder.kt index 8ee241c018..079d89e29d 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/answer/CommunityAnswerItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/answer/CommunityAnswerItemViewHolder.kt @@ -41,7 +41,7 @@ class CommunityAnswerItemViewHolder(val binding: CommunityAnswerItemBinding) : B val intent = CommentActivity.getAnswerCommentIntent(itemView.context, entity.id!!, entity.commentCount, - "", true) + "", entity.commentCount == 0) itemView.context.startActivity(intent) } @@ -56,7 +56,7 @@ class CommunityAnswerItemViewHolder(val binding: CommunityAnswerItemBinding) : B val intent = CommentActivity.getArticleCommentIntent(itemView.context, entity.id, entity.count.comment, - "", true, entity.community.name) + "", entity.count.comment == 0, entity.community.name) itemView.context.startActivity(intent) } diff --git a/app/src/main/java/com/gh/gamecenter/qa/answer/detail/AnswerDetailFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/answer/detail/AnswerDetailFragment.kt index 840600b3dd..0b138c1869 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/answer/detail/AnswerDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/answer/detail/AnswerDetailFragment.kt @@ -923,12 +923,12 @@ class AnswerDetailFragment : NormalFragment() { private fun updateCollectView(isCollected: Boolean) { if (isCollected) { mBinding.bottomController.tvCollect.text = "已收藏" - mBinding.bottomController.ivCollect.setImageResource(R.drawable.ic_collect_highlighted) + mBinding.bottomController.ivCollect.setImageResource(R.drawable.community_content_detail_collect_select) mBinding.bottomController.tvCollect.setTextColor(ContextCompat.getColor(requireContext(), R.color.theme)) } else { mBinding.bottomController.tvCollect.text = "收藏" - mBinding.bottomController.ivCollect.setImageResource(R.drawable.ic_collect_normal) - mBinding.bottomController.tvCollect.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_3a3a3a)) + mBinding.bottomController.ivCollect.setImageResource(R.drawable.community_content_detail_collect_unselect) + mBinding.bottomController.tvCollect.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_242529)) } } @@ -1142,19 +1142,19 @@ class AnswerDetailFragment : NormalFragment() { private fun updateLikeView(alreadyVoted: Boolean, voteCount: Int) { mBinding.bottomController.tvLike.text = "赞同 ${NumberUtils.transSimpleCount(voteCount)}" if (alreadyVoted) { - mBinding.bottomController.ivLike.setImageResource(R.drawable.ic_like_highlighted) + mBinding.bottomController.ivLike.setImageResource(R.drawable.community_content_detail_vote_select) mBinding.bottomController.tvLike.setTextColor(ContextCompat.getColor(context!!, R.color.theme)) } else { - mBinding.bottomController.ivLike.setImageResource(R.drawable.ic_like_normal) - mBinding.bottomController.tvLike.setTextColor(ContextCompat.getColor(context!!, R.color.text_3a3a3a)) + mBinding.bottomController.ivLike.setImageResource(R.drawable.community_content_detail_vote_unselect) + mBinding.bottomController.tvLike.setTextColor(ContextCompat.getColor(context!!, R.color.text_242529)) } } private fun updateDislikeView(disliked: Boolean) { if (disliked) { - mBinding.bottomController.ivDislike.setImageResource(R.drawable.ic_dislike_highlighted) + mBinding.bottomController.ivDislike.setImageResource(R.drawable.community_content_detail_oppose_select) } else { - mBinding.bottomController.ivDislike.setImageResource(R.drawable.ic_dislike_normal) + mBinding.bottomController.ivDislike.setImageResource(R.drawable.community_content_detail_oppose_unselect) } } diff --git a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentAdapter.java b/app/src/main/java/com/gh/gamecenter/qa/comment/CommentAdapter.java deleted file mode 100644 index dd41cdf9be..0000000000 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentAdapter.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.gh.gamecenter.qa.comment; - -import android.content.Context; -import android.text.TextUtils; -import android.view.View; -import android.view.ViewGroup; - -import com.gh.common.constant.ItemViewType; -import com.gh.common.util.CommentHelper; -import com.gh.common.util.CommentUtils; -import com.gh.common.util.DirectUtils; -import com.gh.gamecenter.R; -import com.gh.gamecenter.adapter.OnCommentCallBackListener; -import com.gh.gamecenter.adapter.viewholder.AnswerCommentViewHolder; -import com.gh.gamecenter.adapter.viewholder.FooterViewHolder; -import com.gh.gamecenter.baselist.ListAdapter; -import com.gh.gamecenter.entity.CommentEntity; -import com.gh.gamecenter.entity.CommentParentEntity; - -import androidx.recyclerview.widget.RecyclerView; - -public class CommentAdapter extends ListAdapter { - - private String mEntrance; - private String mAnswerId; - private String mArticleId; - private String mArticleCommunityId; - private boolean mIsShowingConversation; - private OnCommentCallBackListener mOnCommentCallBackListener; - - public CommentAdapter(Context context, String articleId, String articleCommunityId, String answerId - , boolean isShowingConversation, OnCommentCallBackListener commentCallBackListener, String entrance) { - super(context); - mEntrance = entrance; - mAnswerId = answerId; - mArticleId = articleId; - mArticleCommunityId = articleCommunityId; - mIsShowingConversation = isShowingConversation; - mOnCommentCallBackListener = commentCallBackListener; - } - - @Override - public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == ItemViewType.LOADING) { - View view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false); - return new FooterViewHolder(view); - } else { - View view = mLayoutInflater.inflate(R.layout.comment_item, parent, false); - return new AnswerCommentViewHolder(view); - } - } - - @Override - public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { - if (holder instanceof AnswerCommentViewHolder) { - initCommentViewHolder((AnswerCommentViewHolder) holder, position); - } else if (holder instanceof FooterViewHolder) { - initFooterViewHolder((FooterViewHolder) holder); - } - } - - @Override - public int getItemViewType(int position) { - if (position == getItemCount() - 1) { - return ItemViewType.LOADING; - } - - return 100; - } - - @Override - public int getItemCount() { - return mEntityList == null || mEntityList.isEmpty() ? 0 : mEntityList.size() + FOOTER_ITEM_COUNT; - } - - private void initCommentViewHolder(final AnswerCommentViewHolder holder, int position) { - final CommentEntity commentEntity = mEntityList.get(position); - - holder.commentLine.setVisibility(View.GONE); - holder.commentLineBottom.setVisibility(View.VISIBLE); - - CommentUtils.setCommentUserView(mContext, holder, commentEntity); - - CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.getTime()); - - holder.commentContentTv.setText(commentEntity.getContent()); - - CommentParentEntity parentUser = commentEntity.getParentUser(); - if (parentUser != null && !TextUtils.isEmpty(parentUser.getName())) { - holder.quoteContainer.setVisibility(View.VISIBLE); - holder.quoteAuthorTv.setText(String.format("@%s", parentUser.getName())); - - String comment; - if (parentUser.getActive()) { - comment = parentUser.getComment(); - holder.quoteContentTv.setTextColor(mContext.getResources().getColor(R.color.text_5d5d5d)); - } else { - comment = mContext.getString(R.string.comment_hide_hint); - holder.quoteContentTv.setTextColor(mContext.getResources().getColor(R.color.text_d5d5d5)); - } - holder.quoteContentTv.setText(comment); - } else { - holder.quoteContainer.setVisibility(View.GONE); - } - - holder.commentLikeIv.setOnClickListener(v -> CommentUtils.likeComment(mContext, mAnswerId, mArticleId, - mArticleCommunityId, "",commentEntity, holder.commentLikeCountTv, holder.commentLikeIv, null)); - - holder.itemView.setOnClickListener(v -> { - if (!TextUtils.isEmpty(mArticleId)) { - CommentHelper.showCommunityArticleCommentOptions(mContext, - commentEntity, - mIsShowingConversation, - mArticleId, - mArticleCommunityId, - mOnCommentCallBackListener); - } else { - CommentHelper.showAnswerCommentOptions(mContext, - commentEntity, - mIsShowingConversation, - mAnswerId, - mOnCommentCallBackListener); - } - }); - String path = TextUtils.isEmpty(mAnswerId) ? "回答详情-评论管理" : "社区文章详情-评论管理"; - holder.commentUserIconDv.setOnClickListener(v -> DirectUtils.directToHomeActivity(mContext, commentEntity.getUser().getId(), mEntrance, path)); - holder.commentUserNameTv.setOnClickListener(v -> DirectUtils.directToHomeActivity(mContext, commentEntity.getUser().getId(), mEntrance, path)); - - if (commentEntity.getPriority() != 0) { - holder.commentBadge.setVisibility(View.VISIBLE); - } else { - holder.commentBadge.setVisibility(View.GONE); - } - } - - private void initFooterViewHolder(FooterViewHolder holder) { - if (mIsNetworkError) { - holder.loading.setVisibility(View.GONE); - holder.hint.setText(R.string.loading_error_network); - } else if (!mIsOver) { - holder.hint.setText(R.string.loading); - holder.loading.setVisibility(View.VISIBLE); - } else if (mEntityList.size() == 0) { - holder.loading.setVisibility(View.GONE); - holder.hint.setText(R.string.comment_empty); - } else { - holder.hint.setText(R.string.comment_nomore); - holder.loading.setVisibility(View.GONE); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentConversationFragment.java b/app/src/main/java/com/gh/gamecenter/qa/comment/CommentConversationFragment.java deleted file mode 100644 index 014cf047b8..0000000000 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentConversationFragment.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.gh.gamecenter.qa.comment; - -import android.annotation.SuppressLint; -import android.app.Application; -import androidx.lifecycle.ViewModelProviders; -import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import android.text.TextUtils; -import android.view.View; -import android.widget.TextView; - -import com.gh.common.util.DirectUtils; -import com.gh.common.util.EntranceUtils; -import com.gh.gamecenter.R; -import com.gh.gamecenter.baselist.ListAdapter; -import com.gh.gamecenter.entity.CommentEntity; -import com.gh.gamecenter.entity.LinkEntity; - -import butterknife.BindView; - -// 评论详情-查看对话 -public class CommentConversationFragment extends CommentFragment { - - @BindView(R.id.answer_comment_content_container) - View commentContainer; - @BindView(R.id.link_tv) - TextView linkTv; - - private String mCommentId; - private String mArticleCommentId; - private LinkEntity mLinkEntity; - - @Override - protected ListAdapter provideListAdapter() { - if (mAdapter == null) { - if (!TextUtils.isEmpty(mAnswerId)) { - mEntrance = "(答案-评论详情-查看对话)"; - } else { - mEntrance = "(文章-评论详情-查看对话)"; - } - mAdapter = new CommentAdapter(getContext(), mArticleId, mCommunityId, - mAnswerId, false, this, mEntrance); - } - return mAdapter; - } - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - mCommentId = getArguments().getString(EntranceUtils.KEY_COMMENTID); - mAnswerId = getArguments().getString(EntranceUtils.KEY_ANSWER_ID); - - mArticleId = getArguments().getString(CommentActivity.ARTICLE_ID); - mArticleCommentId = getArguments().getString(EntranceUtils.KEY_ARTICLE_COMMENT_ID); - mCommunityId = getArguments().getString(CommentActivity.COMMUNITY_ID); - mLinkEntity = getArguments().getParcelable(EntranceUtils.KEY_LINK); - super.onCreate(savedInstanceState); - } - - @SuppressLint("ClickableViewAccessibility") - @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - commentContainer.setVisibility(View.GONE); - setNavigationTitle("查看对话"); - - mListRv.setOnTouchListener((v, event) -> { - if (commentContainer.getVisibility() == View.VISIBLE) { - commentContainer.setVisibility(View.GONE); - } - return false; - }); - - if (mLinkEntity != null) { - linkTv.setVisibility(View.VISIBLE); - linkTv.setText((("answer".equals(mLinkEntity.getType()) ? "回答:" : "文章:") + mLinkEntity.getTitle())); - linkTv.setOnClickListener(v -> { - DirectUtils.directToLinkPage(getContext(), mLinkEntity, mEntrance, "查看对话"); - }); - } - } - - @Override - protected int getLayoutId() { - return R.layout.fragment_answer_comment_conversation; - } - - @Override - protected CommentViewModel provideListViewModel() { - return ViewModelProviders.of(this, new CommentViewModel.Factory((Application) getContext().getApplicationContext() - , mAnswerId, mCommentId, mArticleId, mCommunityId, mArticleCommentId)).get(CommentViewModel.class); - } - - @Override - public void onCommentCallback(CommentEntity entity) { - commentContainer.setVisibility(View.VISIBLE); - mCommentEntity = entity; - setSoftInput(true); - } -} diff --git a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentFragment.java b/app/src/main/java/com/gh/gamecenter/qa/comment/CommentFragment.java deleted file mode 100644 index 4ac26c571c..0000000000 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentFragment.java +++ /dev/null @@ -1,388 +0,0 @@ -package com.gh.gamecenter.qa.comment; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.app.Application; -import android.app.Dialog; -import android.content.Context; -import android.os.Bundle; -import android.text.Editable; -import android.text.InputFilter; -import android.text.TextUtils; -import android.text.TextWatcher; -import android.util.DisplayMetrics; -import android.view.View; -import android.view.ViewGroup; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.FrameLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.Fragment; -import androidx.lifecycle.ViewModelProviders; -import androidx.recyclerview.widget.RecyclerView; - -import com.gh.base.fragment.BaseDialogWrapperFragment; -import com.gh.common.util.CheckLoginUtils; -import com.gh.common.util.ClickUtils; -import com.gh.common.util.DialogUtils; -import com.gh.common.util.ErrorHelper; -import com.gh.common.util.KeyboardHeightObserver; -import com.gh.common.util.KeyboardHeightProvider; -import com.gh.common.util.PermissionHelper; -import com.gh.common.util.TextHelper; -import com.gh.common.view.VerticalItemDecoration; -import com.gh.gamecenter.R; -import com.gh.gamecenter.adapter.OnCommentCallBackListener; -import com.gh.gamecenter.baselist.ListAdapter; -import com.gh.gamecenter.baselist.ListFragment; -import com.gh.gamecenter.entity.CommentEntity; -import com.gh.gamecenter.qa.answer.detail.AnswerDetailFragment; -import com.halo.assistant.HaloApp; -import com.lightgame.utils.Util_System_Keyboard; - -import butterknife.BindView; -import butterknife.OnClick; -import butterknife.Optional; -import retrofit2.HttpException; - -public class CommentFragment extends ListFragment implements OnCommentCallBackListener, KeyboardHeightObserver { - - @Nullable - @BindView(R.id.answer_comment_container) - protected View mCommentContainer; - @BindView(R.id.answer_comment_et) - protected EditText mCommentDetailCommentEt; - @BindView(R.id.answer_comment_send_btn) - protected TextView mCommentSend; - @Nullable - @BindView(R.id.answer_comment_dialog_count_tv) - protected TextView mCommentCountTv; - @Nullable - @BindView(R.id.answer_comment_content_container) - View mCommentInputContainer; - - private int mOffset; - protected int mCommentCount; - protected String mAnswerId; - protected String mArticleId; - private String mCommentDraft; - protected String mCommunityId; - - protected boolean mShowSoftKeyboardOnStartUp; - - protected CommentEntity mCommentEntity; // 回复评论的实体 用完马上清空 - protected CommentAdapter mAdapter; - private KeyboardHeightProvider mKeyboardHeightProvider; - private AnswerDetailFragment.CommentListener mCommentListener; - protected Dialog mSendingDialog; - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - mListViewModel.getPostCommentLiveData().observe(this, apiResponse -> { - if (apiResponse == null) return; - - if (apiResponse.getData() != null) { - mSendingDialog.dismiss(); - toast("发表成功"); - mCommentDetailCommentEt.setText(""); - - mCommentCount++; - updateCommentCount(); - onRefresh(); - - if (mCommentListener != null) { - mCommentListener.onCountChange(mCommentCount); - mCommentListener.onCommentDraftChange(""); - } - mCommentDetailCommentEt.postDelayed(() -> setSoftInput(false), 100); - } else if (apiResponse.getHttpException() != null) { - mSendingDialog.dismiss(); - - HttpException exception = apiResponse.getHttpException(); - String errorString = null; - try { - errorString = exception.response().errorBody().string(); - } catch (Exception e1) { - e1.printStackTrace(); - } - ErrorHelper.handleError(requireContext(), errorString, false); - } else { - mSendingDialog.dismiss(); - toast(R.string.post_failure_hint); - } - }); - } - - @SuppressLint("DefaultLocale") - @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - mCommentDetailCommentEt.setFocusable(true); - mCommentDetailCommentEt.setFocusableInTouchMode(true); -// mCommentDetailCommentEt.requestFocus(); // 设置后setOnFocusChangeListener无响应 - mCommentDetailCommentEt.addTextChangedListener(watcher); - mCommentDetailCommentEt.setFilters(new InputFilter[]{TextHelper.getFilter(140, "评论不能多于140字")}); - mCommentDetailCommentEt.setText(mCommentDraft); - mCommentDetailCommentEt.setSelection(mCommentDetailCommentEt.getText().length()); - if (mShowSoftKeyboardOnStartUp) { - mCommentDetailCommentEt.postDelayed(() -> { - InputMethodManager keyboard = (InputMethodManager) - HaloApp.getInstance().getApplication().getSystemService(Context.INPUT_METHOD_SERVICE); - keyboard.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); - }, 200); - } else { - mCommentDetailCommentEt.clearFocus(); - mCommentSend.setBackgroundDrawable(getResources().getDrawable(R.drawable.button_gray_style)); - } - - mCommentDetailCommentEt.setOnFocusChangeListener((v, hasFocus) -> { - if (hasFocus) { - mCommentDetailCommentEt.setHintTextColor(ContextCompat.getColor(getContext(), R.color.hint)); - } else { - mCommentDetailCommentEt.setHintTextColor(ContextCompat.getColor(getContext(), R.color.theme)); - } - }); - - updateCommentCount(); - - if (mCommentContainer != null) { - DisplayMetrics displayMetrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); - - mCommentContainer.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, displayMetrics.heightPixels * 34 / 55)); - } - - mKeyboardHeightProvider = new KeyboardHeightProvider(getActivity()); - view.post(() -> mKeyboardHeightProvider.start()); - } - - @Override - public void onResume() { - super.onResume(); - // 在查看对话页面不需要手动处理软键盘的高度 - if (!(this instanceof CommentConversationFragment)) { - mKeyboardHeightProvider.setKeyboardHeightObserver(this); - } - } - - @Override - public void onPause() { - super.onPause(); - mKeyboardHeightProvider.setKeyboardHeightObserver(null); - } - - @Override - public void onDestroy() { - super.onDestroy(); - mKeyboardHeightProvider.close(); - } - - private void updateCommentCount() { - if (mCommentCountTv != null) { - mCommentCountTv.setText(String.format("%d条评论", mCommentCount)); - } - } - - @Override - protected RecyclerView.ItemDecoration getItemDecoration() { - return new VerticalItemDecoration(getContext(), 0, true); - } - - @Override - protected CommentViewModel provideListViewModel() { - return ViewModelProviders.of(this, new CommentViewModel.Factory((Application) getContext().getApplicationContext(), - mAnswerId, null, mArticleId, mCommunityId, null)).get(CommentViewModel.class); - } - - @Override - protected ListAdapter provideListAdapter() { - if (mAdapter == null) { - String entrance; - if (!TextUtils.isEmpty(mAnswerId)) { - entrance = "(答案详情-评论列表)"; - } else { - entrance = "(文章详情-评论列表)"; - } - mAdapter = new CommentAdapter(getContext(), mArticleId, mCommunityId, - mAnswerId, true, this, entrance); - } - return mAdapter; - } - - @Override - protected int getLayoutId() { - return R.layout.fragment_answer_comment; - } - - public static CommentFragment getInstance(String answerId, boolean showSoftKeyboardOnStartUp - , int commentCount, String commentDraft, AnswerDetailFragment.CommentListener listener) { - CommentFragment fragment = new CommentFragment(); - fragment.mShowSoftKeyboardOnStartUp = showSoftKeyboardOnStartUp; - fragment.mAnswerId = answerId; - fragment.mCommentCount = commentCount; - fragment.mCommentListener = listener; - fragment.mCommentDraft = commentDraft; - return fragment; - } - - public static CommentFragment getArticleInstance(String articleId - , String articleCommunityId, boolean showSoftKeyboardOnStartUp - , int commentCount, String commentDraft, AnswerDetailFragment.CommentListener listener) { - CommentFragment fragment = new CommentFragment(); - fragment.mShowSoftKeyboardOnStartUp = showSoftKeyboardOnStartUp; - fragment.mArticleId = articleId; - fragment.mCommentCount = commentCount; - fragment.mCommentListener = listener; - fragment.mCommentDraft = commentDraft; - fragment.mCommunityId = articleCommunityId; - return fragment; - } - - private TextWatcher watcher = new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - if (s.toString().trim().length() > 0) { - mCommentSend.setEnabled(true); - mCommentSend.setBackgroundDrawable(getResources().getDrawable(R.drawable.button_normal_style)); - } else { - mCommentSend.setEnabled(false); - mCommentSend.setBackgroundDrawable(getResources().getDrawable(R.drawable.button_gray_style)); - } - - if (mCommentListener != null) { - mCommentListener.onCommentDraftChange(mCommentDetailCommentEt.getText().toString()); - } - } - - @Override - public void afterTextChanged(Editable s) { - } - }; - - @Override - public void onCommentCallback(CommentEntity entity) { - mCommentEntity = entity; - setSoftInput(true); - } - - @Optional - @OnClick({ - R.id.answer_comment_container, - R.id.answer_comment_send_btn, - R.id.answer_comment_close_iv, - R.id.answer_comment_title_container}) - public void onClick(View view) { - switch (view.getId()) { - case R.id.answer_comment_send_btn: - if (!ClickUtils.isFastDoubleClick(R.id.answer_comment_send_btn, 5000)) { - String entrance = "回答详情-评论-写评论"; - if (TextUtils.isEmpty(mArticleId)) { - entrance = "社区文章详情-评论-写评论"; - } - CheckLoginUtils.checkLogin(getContext(), entrance, () -> { - PermissionHelper.checkReadPhoneStatePermissionBeforeAction(requireContext(), this::postComment); - }); - } else { - toast("操作太快,慢一点嘛"); - } - break; - case R.id.answer_comment_close_iv: - setSoftInput(false); - Fragment fragment = getParentFragment(); - if (fragment instanceof BaseDialogWrapperFragment) { - ((BaseDialogWrapperFragment) fragment).dismiss(); - } - if (getActivity() instanceof CommentActivity) { - getActivity().finish(); - } - break; - } - } - - private void postComment() { - final String content = mCommentDetailCommentEt.getText().toString(); - - if (content.length() == 0) { - toast("评论内容不能为空!"); - return; - } - - mSendingDialog = DialogUtils.showWaitDialog(getContext(), getString(R.string.post_dialog_hint)); - - if (mCommentEntity != null && mCommentEntity.getId() == null) { - toast("评论异常 id null"); - mSendingDialog.cancel(); - return; - } - - mListViewModel.postComment(content, mCommentEntity); - } - - //软键盘控制 - protected void setSoftInput(boolean isShow) { - if (isShow) { - String entrance; - if (TextUtils.isEmpty(mArticleId)) { - if (mCommentEntity != null) { - entrance = "社区文章详情-评论-写评论"; - } else { - entrance = "社区文章详情-评论-回复"; - } - } else { - if (mCommentEntity != null) { - entrance = "回答详情-评论-写评论"; - } else { - entrance = "回答详情-评论-回复"; - } - } - CheckLoginUtils.checkLogin(getContext(), entrance, () -> { - InputMethodManager keyboard = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - keyboard.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); - mCommentDetailCommentEt.setFocusable(true); - mCommentDetailCommentEt.setFocusableInTouchMode(true); - mCommentDetailCommentEt.requestFocus(); - - if (mCommentEntity != null && mCommentEntity.getUser() != null) { - mCommentDetailCommentEt.setHint(getString(R.string.comment_repty_hint, mCommentEntity.getUser().getName())); - } else { - mCommentDetailCommentEt.setHint(getString(R.string.message_detail_comment_hint)); - } - }); - } else { - Util_System_Keyboard.hideSoftKeyboard(getContext(), mCommentDetailCommentEt); - - if (mCommentEntity != null) { - mCommentEntity = null; // 清空当前评论实体 - mCommentDetailCommentEt.setHint(getString(R.string.message_detail_comment_hint)); - mCommentDetailCommentEt.setText(""); - } - } - } - - @Override - public void onKeyboardHeightChanged(int height, int orientation) { - if (mCommentInputContainer != null && mCommentInputContainer.getVisibility() != View.GONE) { - RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mCommentInputContainer.getLayoutParams(); - if (height > 0) { - lp.bottomMargin = height + mOffset; - } else { - mOffset = Math.abs(height); - lp.bottomMargin = 0; - } - - mCommentInputContainer.setLayoutParams(lp); - } - } -} diff --git a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentViewModel.java b/app/src/main/java/com/gh/gamecenter/qa/comment/CommentViewModel.java deleted file mode 100644 index 8fa2f405de..0000000000 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentViewModel.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.gh.gamecenter.qa.comment; - -import android.app.Application; -import androidx.lifecycle.LiveData; -import androidx.lifecycle.MutableLiveData; -import androidx.lifecycle.ViewModel; -import androidx.lifecycle.ViewModelProvider; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import android.text.TextUtils; - -import com.gh.common.util.PostCommentUtils; -import com.gh.gamecenter.baselist.ListViewModel; -import com.gh.gamecenter.entity.CommentEntity; -import com.gh.gamecenter.retrofit.RetrofitManager; -import com.gh.gamecenter.retrofit.service.ApiService; -import com.gh.gamecenter.user.ApiResponse; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.util.List; - -import io.reactivex.Observable; -import retrofit2.HttpException; - -public class CommentViewModel extends ListViewModel { - - private String mAnswerId; - private String mCommentId; - private String mArticleId; - private String mArticleCommentId; - private String mArticleCommunityId; - - private MutableLiveData> mPostCommentLiveData = new MutableLiveData<>(); - - public CommentViewModel(@NonNull Application application, String answerId, @Nullable String commentId - , String articleId, String articleCommunityId, String articleCommentId) { - super(application); - mAnswerId = answerId; - mCommentId = commentId; - mArticleId = articleId; - mArticleCommunityId = articleCommunityId; - mArticleCommentId = articleCommentId; - } - - @Override - public Observable> provideDataObservable(int page) { - ApiService api = RetrofitManager.getInstance(getApplication()).getApi(); - if (!TextUtils.isEmpty(mArticleCommentId)) { - return api.getCommunityArticleCommentConversation(mArticleCommunityId, mArticleId, mArticleCommentId, page); - } else if (!TextUtils.isEmpty(mArticleId)) { - return api.getCommunityArticleCommentList(mArticleCommunityId, mArticleId, page); - } else if (TextUtils.isEmpty(mCommentId)) { - return api.getAnswerCommentList(mAnswerId, page); - } else { - return api.getAnswerCommentConversationList(mAnswerId, mCommentId, page); - } -// return RetrofitManager.getInstance(getApplication()).getApi().getComment("59c0b965e9a64abe2a423544", 0, offset); - } - - public void postComment(String content, CommentEntity commentEntity) { - - JSONObject jsonObject = new JSONObject(); - try { - jsonObject.put("content", content); - } catch (JSONException e) { - e.printStackTrace(); - } - - PostCommentUtils.addAnswerComment(getApplication(), mAnswerId, mArticleId, mArticleCommunityId,jsonObject.toString(), commentEntity, - new PostCommentUtils.PostCommentListener() { - @Override - public void postSuccess(JSONObject response) { - ApiResponse apiResponse = new ApiResponse<>(); - apiResponse.setData(response); - mPostCommentLiveData.postValue(apiResponse); - } - - @Override - public void postFailed(Throwable e) { - ApiResponse apiResponse = new ApiResponse<>(); - if (e instanceof HttpException) { - apiResponse.setHttpException((HttpException) e); - mPostCommentLiveData.postValue(apiResponse); - } else { - mPostCommentLiveData.postValue(apiResponse); - } - } - }); - } - - public LiveData> getPostCommentLiveData() { - return mPostCommentLiveData; - } - - @Override - protected void mergeResultLiveData() { - mResultLiveData.addSource(mListLiveData, mResultLiveData::postValue); - } - - public static class Factory extends ViewModelProvider.NewInstanceFactory { - private Application mApplication; - private String mAnswerId; - private String mCommentId; - private String mArticleId; - private String mArticleCommentId; - private String mArticleCommunityId; - - public Factory(Application application, String answerId, String commentId - , String articleId, String articleCommunityId, String articleCommentId) { - mApplication = application; - mAnswerId = answerId; - mCommentId = commentId; - mArticleId = articleId; - mArticleCommentId = articleCommentId; - mArticleCommunityId = articleCommunityId; - } - - @Override - public T create(Class modelClass) { - return (T) new CommentViewModel(mApplication, mAnswerId, mCommentId, mArticleId, mArticleCommunityId, mArticleCommentId); - } - } -} diff --git a/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentAdapter.kt index 08f7cf2fe4..2534282570 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/comment/NewCommentAdapter.kt @@ -7,12 +7,14 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.gh.common.constant.ItemViewType import com.gh.common.util.* +import com.gh.gamecenter.MessageDetailActivity import com.gh.gamecenter.R import com.gh.gamecenter.adapter.OnCommentCallBackListener import com.gh.gamecenter.adapter.viewholder.AnswerCommentViewHolder import com.gh.gamecenter.adapter.viewholder.FooterViewHolder import com.gh.gamecenter.baselist.ListAdapter import com.gh.gamecenter.entity.CommentEntity +import com.lightgame.utils.Utils class NewCommentAdapter(context: Context, var mViewModel: NewCommentViewModel, @@ -50,12 +52,7 @@ class NewCommentAdapter(context: Context, private fun initCommentViewHolder(holder: AnswerCommentViewHolder, position: Int) { val commentEntity = mEntityList[position] - - holder.commentLine.visibility = View.GONE - holder.commentLineBottom.visibility = View.VISIBLE - CommentUtils.setCommentUserView(mContext, holder, commentEntity) - CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.time) if (!TextUtils.isEmpty(mViewModel.videoId)) { @@ -123,7 +120,13 @@ class NewCommentAdapter(context: Context, mViewModel.communityId, mViewModel.videoId, commentEntity, holder.commentLikeCountTv, holder.commentLikeIv, null) } - holder.itemView.setOnClickListener { + holder.commentReply.setOnClickListener { + mContext.ifLogin("回答详情-评论-回复") { + mCommentCallBackListener.onCommentCallback(commentEntity) + } + } + + holder.commentMore.setOnClickListener { when (mViewModel.commentType) { CommentType.ANSWER, CommentType.ANSWER_CONVERSATION -> { diff --git a/app/src/main/res/drawable-xhdpi/vote_icon_select.png b/app/src/main/res/drawable-xhdpi/vote_icon_select.png deleted file mode 100644 index 22774bc86e..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/vote_icon_select.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/vote_icon_unselect.png b/app/src/main/res/drawable-xhdpi/vote_icon_unselect.png deleted file mode 100644 index 91abaf00e6..0000000000 Binary files a/app/src/main/res/drawable-xhdpi/vote_icon_unselect.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/comment_vote_select.png b/app/src/main/res/drawable-xxhdpi/comment_vote_select.png new file mode 100644 index 0000000000..0fb60b1b22 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/comment_vote_select.png differ diff --git a/app/src/main/res/drawable-xxhdpi/comment_vote_unselect.png b/app/src/main/res/drawable-xxhdpi/comment_vote_unselect.png new file mode 100644 index 0000000000..af5a54b61c Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/comment_vote_unselect.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_comment_close.png b/app/src/main/res/drawable-xxhdpi/community_comment_close.png new file mode 100644 index 0000000000..c9e0ac4ff9 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_comment_close.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_comment_more.png b/app/src/main/res/drawable-xxhdpi/community_comment_more.png new file mode 100644 index 0000000000..cf95c4c335 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_comment_more.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_content_detail_collect_select.png b/app/src/main/res/drawable-xxhdpi/community_content_detail_collect_select.png new file mode 100644 index 0000000000..76b708a459 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_content_detail_collect_select.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_content_detail_collect_unselect.png b/app/src/main/res/drawable-xxhdpi/community_content_detail_collect_unselect.png new file mode 100644 index 0000000000..6852cd6f4f Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_content_detail_collect_unselect.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_content_detail_comment.png b/app/src/main/res/drawable-xxhdpi/community_content_detail_comment.png new file mode 100644 index 0000000000..b34c5cdfd2 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_content_detail_comment.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_content_detail_oppose_select.png b/app/src/main/res/drawable-xxhdpi/community_content_detail_oppose_select.png new file mode 100644 index 0000000000..f59d5c9c24 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_content_detail_oppose_select.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_content_detail_oppose_unselect.png b/app/src/main/res/drawable-xxhdpi/community_content_detail_oppose_unselect.png new file mode 100644 index 0000000000..1d781c5df4 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_content_detail_oppose_unselect.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_content_detail_share.png b/app/src/main/res/drawable-xxhdpi/community_content_detail_share.png new file mode 100644 index 0000000000..ddabf9f2f8 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_content_detail_share.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_content_detail_vote_select.png b/app/src/main/res/drawable-xxhdpi/community_content_detail_vote_select.png new file mode 100644 index 0000000000..e152bd2a94 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_content_detail_vote_select.png differ diff --git a/app/src/main/res/drawable-xxhdpi/community_content_detail_vote_unselect.png b/app/src/main/res/drawable-xxhdpi/community_content_detail_vote_unselect.png new file mode 100644 index 0000000000..687dcfa6a8 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/community_content_detail_vote_unselect.png differ diff --git a/app/src/main/res/drawable/community_comment_background.xml b/app/src/main/res/drawable/community_comment_background.xml new file mode 100644 index 0000000000..836bdfba0f --- /dev/null +++ b/app/src/main/res/drawable/community_comment_background.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/community_comment_reply_background.xml b/app/src/main/res/drawable/community_comment_reply_background.xml new file mode 100644 index 0000000000..dee31678cb --- /dev/null +++ b/app/src/main/res/drawable/community_comment_reply_background.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/community_content_detail_vote_background.xml b/app/src/main/res/drawable/community_content_detail_vote_background.xml new file mode 100644 index 0000000000..da7df63ef9 --- /dev/null +++ b/app/src/main/res/drawable/community_content_detail_vote_background.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/comment_item.xml b/app/src/main/res/layout/comment_item.xml index 0388c2c52c..6617851aab 100644 --- a/app/src/main/res/layout/comment_item.xml +++ b/app/src/main/res/layout/comment_item.xml @@ -5,259 +5,281 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/reuse_listview_item_style" - android:gravity="center_vertical" android:orientation="vertical"> - - - + android:layout_marginLeft="20dp" + android:layout_marginTop="12dp" + android:layout_marginRight="10dp"> + + + + + + + + android:layout_alignTop="@id/comment_icon_container" + android:layout_marginLeft="12dp" + android:layout_marginBottom="12dp" + android:layout_toRightOf="@+id/comment_icon_container"> - - - - - - - - - - - - - - - - - - - + android:layout_marginRight="2dp" + android:layout_toLeftOf="@id/command_container"> - - + android:ellipsize="end" + android:maxLines="1" + android:textColor="@color/text_666666" + android:textSize="12sp" + app:layout_constrainedWidth="true" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/comment_author" + app:layout_constraintHorizontal_bias="0" + app:layout_constraintHorizontal_chainStyle="packed" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:text="孙一峰" /> - + - - + - + + + + + + + + + + + + + + + + android:textColor="@color/text_333333" + android:textSize="14sp" + tools:text="星際爭霸與星際爭霸2的職業選電競戰隊的經理美少女团体星際老男孩成員之一,還在杭州經營水產生意。" /> - + android:layout_below="@+id/comment_content" + android:layout_marginTop="8dp" + android:includeFontPadding="false" + android:textColor="@color/text_999999" + android:textSize="12sp" + tools:text="一个小时前" /> - - + + + - - - - + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_comment.xml b/app/src/main/res/layout/fragment_comment.xml index 93941299bb..1bb34d5e20 100644 --- a/app/src/main/res/layout/fragment_comment.xml +++ b/app/src/main/res/layout/fragment_comment.xml @@ -8,7 +8,7 @@ android:id="@+id/comment_container" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/white" + android:background="@drawable/community_comment_background" android:orientation="vertical"> + android:src="@drawable/community_comment_close" /> - - diff --git a/app/src/main/res/layout/piece_article_bottom.xml b/app/src/main/res/layout/piece_article_bottom.xml index c912ab423f..2c33d9d5ff 100644 --- a/app/src/main/res/layout/piece_article_bottom.xml +++ b/app/src/main/res/layout/piece_article_bottom.xml @@ -7,8 +7,8 @@ android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignParentBottom="true" - android:clickable="true" - android:background="@android:color/white"> + android:background="@android:color/white" + android:clickable="true"> + android:paddingLeft="12dp" + android:paddingRight="12dp"> + android:src="@drawable/community_content_detail_vote_unselect" /> + android:textColor="@color/text_242529" + android:textSize="11sp" /> @@ -46,7 +46,7 @@ android:layout_centerVertical="true" android:layout_marginLeft="6dp" android:layout_toRightOf="@id/container_like" - android:background="@drawable/round_grey_bg" + android:background="@drawable/community_content_detail_vote_background" android:gravity="center" android:orientation="horizontal" android:paddingLeft="10dp" @@ -56,7 +56,7 @@ android:id="@+id/iv_dislike" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_dislike_normal" /> + android:src="@drawable/community_content_detail_oppose_unselect" /> @@ -76,30 +76,33 @@ android:layout_marginRight="26dp" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"> + + android:src="@drawable/community_content_detail_comment" /> + android:paddingTop="4dp" + android:text="评论 0" + android:includeFontPadding="false" + android:textColor="@color/text_242529" + android:textSize="10sp" /> + @@ -107,9 +110,10 @@ android:id="@+id/tv_collect" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingTop="2dp" + android:includeFontPadding="false" + android:paddingTop="4dp" android:text="收藏" - android:textColor="@color/text_3a3a3a" + android:textColor="@color/text_242529" android:textSize="10sp" app:layout_constraintLeft_toLeftOf="@id/iv_collect" app:layout_constraintRight_toRightOf="@id/iv_collect" @@ -120,7 +124,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="32dp" - android:src="@drawable/ic_share" + android:src="@drawable/community_content_detail_share" app:layout_constraintRight_toLeftOf="@id/iv_collect" app:layout_constraintTop_toTopOf="parent" /> @@ -128,9 +132,10 @@ android:id="@+id/tv_share" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingTop="2dp" + android:includeFontPadding="false" + android:paddingTop="4dp" android:text="分享" - android:textColor="@color/text_3a3a3a" + android:textColor="@color/text_242529" android:textSize="10sp" app:layout_constraintLeft_toLeftOf="@id/iv_share" app:layout_constraintRight_toRightOf="@id/iv_share" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 11459a7ba1..64ccd96233 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -146,4 +146,5 @@ #A1A5B7 #50556B #979A9F + #242529 \ No newline at end of file