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 83c7141a19..eced33ffe1 100644 --- a/app/src/main/java/com/gh/common/util/CommentHelper.kt +++ b/app/src/main/java/com/gh/common/util/CommentHelper.kt @@ -79,7 +79,10 @@ object CommentHelper { } } - "查看对话" -> context.startActivity(CommentDetailActivity.getCommunityArticleCommentIntent(context, articleId, commentEntity.id, communityId)); + "查看对话" -> { + context.startActivity(CommentDetailActivity + .getCommunityArticleCommentIntent(context, articleId, commentEntity.id, communityId, null)) + } } } @@ -143,7 +146,10 @@ object CommentHelper { } } - "查看对话" -> context.startActivity(CommentDetailActivity.getAnswerCommentIntent(context, commentEntity.id, answerId)) + "查看对话" -> { + context.startActivity(CommentDetailActivity + .getAnswerCommentIntent(context, commentEntity.id, answerId, null)) + } } } 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 c7a7a840a3..5b58ba1370 100644 --- a/app/src/main/java/com/gh/common/util/CommentUtils.java +++ b/app/src/main/java/com/gh/common/util/CommentUtils.java @@ -256,134 +256,134 @@ public class CommentUtils { } - public static void showAnswerCommentOptions(final CommentEntity commentEntity, final Context context, - final OnCommentCallBackListener listener, final String id, - boolean showConversation, String answerId, String articleId, String articleCommunityId) { +// public static void showAnswerCommentOptions(final CommentEntity commentEntity, final Context context, +// final OnCommentCallBackListener listener, final String id, +// boolean showConversation, String answerId, String articleId, String articleCommunityId) { +// +// final Dialog dialog = new Dialog(context); +// +// LinearLayout container = new LinearLayout(context); +// container.setOrientation(LinearLayout.VERTICAL); +// container.setBackgroundColor(Color.WHITE); +// container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12)); +// +// List dialogType = new ArrayList<>(); +// +// if (commentEntity.getMe() == null || !commentEntity.getMe().isAnswerCommented()) { +// dialogType.add("回复"); +// } +// +// dialogType.add("复制"); +// dialogType.add("举报"); +// +// if (commentEntity.getParentUser() != null && showConversation) { +// dialogType.add("查看对话"); +// } +// +// for (String s : dialogType) { +// final TextView reportTv = new TextView(context); +// reportTv.setText(s); +// reportTv.setTextSize(17); +// reportTv.setTextColor(ContextCompat.getColor(context, R.color.title)); +// reportTv.setBackgroundResource(R.drawable.textview_white_style); +// int widthPixels = context.getResources().getDisplayMetrics().widthPixels; +// reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10, +// LinearLayout.LayoutParams.WRAP_CONTENT)); +// reportTv.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 12), +// 0, DisplayUtils.dip2px(context, 12)); +// container.addView(reportTv); +// +// reportTv.setOnClickListener(v -> { +// dialog.cancel(); +// switch (reportTv.getText().toString()) { +// case "回复": +// CheckLoginUtils.checkLogin(context, () -> { +// if (listener != null) { +// listener.onCommentCallback(commentEntity); +// } else if (!TextUtils.isEmpty(id)) { +// context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, id)); +// } else { +// Utils.toast(context, "缺少关键属性"); +// } +// }); +// break; +// case "复制": +// copyText(commentEntity.getContent(), context); +// break; +// case "举报": +// CheckLoginUtils.checkLogin(context, () -> showAnswerReportDialog(answerId, commentEntity, context)); +// break; +// case "查看对话": +// if (TextUtils.isEmpty(articleId)) { +// context.startActivity(CommentDetailActivity.getAnswerCommentIntent(context, commentEntity.getId(), answerId, null)); +// } else { +// context.startActivity(CommentDetailActivity.getCommunityArticleCommentIntent(context, articleId, commentEntity.getId(), articleCommunityId, null)); +// } +// break; +// } +// }); +// } +// +// dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); +// dialog.setContentView(container); +// dialog.show(); +// } - final Dialog dialog = new Dialog(context); - - LinearLayout container = new LinearLayout(context); - container.setOrientation(LinearLayout.VERTICAL); - container.setBackgroundColor(Color.WHITE); - container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12)); - - List dialogType = new ArrayList<>(); - - if (commentEntity.getMe() == null || !commentEntity.getMe().isAnswerCommented()) { - dialogType.add("回复"); - } - - dialogType.add("复制"); - dialogType.add("举报"); - - if (commentEntity.getParentUser() != null && showConversation) { - dialogType.add("查看对话"); - } - - for (String s : dialogType) { - final TextView reportTv = new TextView(context); - reportTv.setText(s); - reportTv.setTextSize(17); - reportTv.setTextColor(ContextCompat.getColor(context, R.color.title)); - reportTv.setBackgroundResource(R.drawable.textview_white_style); - int widthPixels = context.getResources().getDisplayMetrics().widthPixels; - reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10, - LinearLayout.LayoutParams.WRAP_CONTENT)); - reportTv.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 12), - 0, DisplayUtils.dip2px(context, 12)); - container.addView(reportTv); - - reportTv.setOnClickListener(v -> { - dialog.cancel(); - switch (reportTv.getText().toString()) { - case "回复": - CheckLoginUtils.checkLogin(context, () -> { - if (listener != null) { - listener.onCommentCallback(commentEntity); - } else if (!TextUtils.isEmpty(id)) { - context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, id)); - } else { - Utils.toast(context, "缺少关键属性"); - } - }); - break; - case "复制": - copyText(commentEntity.getContent(), context); - break; - case "举报": - CheckLoginUtils.checkLogin(context, () -> showAnswerReportDialog(answerId, commentEntity, context)); - break; - case "查看对话": - if (TextUtils.isEmpty(articleId)) { - context.startActivity(CommentDetailActivity.getAnswerCommentIntent(context, commentEntity.getId(), answerId)); - } else { - context.startActivity(CommentDetailActivity.getCommunityArticleCommentIntent(context, articleId, commentEntity.getId(), articleCommunityId)); - } - break; - } - }); - } - - dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); - dialog.setContentView(container); - dialog.show(); - } - - private static void showAnswerReportDialog(final String answerId, final CommentEntity commentEntity, final Context context) { - final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息", - "违法有害信息", "其它"}; - int widthPixels = context.getResources().getDisplayMetrics().widthPixels; - - final Dialog reportTypeDialog = new Dialog(context); - LinearLayout container = new LinearLayout(context); - container.setOrientation(LinearLayout.VERTICAL); - container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12)); - container.setBackgroundColor(Color.WHITE); - - for (final String s : arrReportType) { - TextView reportTypeTv = new TextView(context); - reportTypeTv.setText(s); - reportTypeTv.setTextSize(17); - reportTypeTv.setTextColor(ContextCompat.getColor(context, R.color.title)); - reportTypeTv.setBackgroundResource(R.drawable.textview_white_style); - reportTypeTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10, - LinearLayout.LayoutParams.WRAP_CONTENT)); - reportTypeTv.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 12), - 0, DisplayUtils.dip2px(context, 12)); - container.addView(reportTypeTv); - - reportTypeTv.setOnClickListener(v -> { - JSONObject jsonObject = new JSONObject(); - try { - jsonObject.put("reason", s); - } catch (JSONException e) { - e.printStackTrace(); - } - - PostCommentUtils.postAnswerReportData(context, commentEntity.getId(), answerId, jsonObject.toString(), - new PostCommentUtils.PostCommentListener() { - @Override - public void postSuccess(JSONObject response) { - Utils.toast(context, "感谢您的举报"); - } - - @Override - public void postFailed(Throwable error) { - if (error != null) { - Utils.toast(context, "举报失败" + error.getMessage()); - } else { - Utils.toast(context, "举报失败,请稍候重试"); - } - } - }); - reportTypeDialog.cancel(); - }); - } - - reportTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); - reportTypeDialog.setContentView(container); - reportTypeDialog.show(); - } +// private static void showAnswerReportDialog(final String answerId, final CommentEntity commentEntity, final Context context) { +// final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息", +// "违法有害信息", "其它"}; +// int widthPixels = context.getResources().getDisplayMetrics().widthPixels; +// +// final Dialog reportTypeDialog = new Dialog(context); +// LinearLayout container = new LinearLayout(context); +// container.setOrientation(LinearLayout.VERTICAL); +// container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12)); +// container.setBackgroundColor(Color.WHITE); +// +// for (final String s : arrReportType) { +// TextView reportTypeTv = new TextView(context); +// reportTypeTv.setText(s); +// reportTypeTv.setTextSize(17); +// reportTypeTv.setTextColor(ContextCompat.getColor(context, R.color.title)); +// reportTypeTv.setBackgroundResource(R.drawable.textview_white_style); +// reportTypeTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10, +// LinearLayout.LayoutParams.WRAP_CONTENT)); +// reportTypeTv.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 12), +// 0, DisplayUtils.dip2px(context, 12)); +// container.addView(reportTypeTv); +// +// reportTypeTv.setOnClickListener(v -> { +// JSONObject jsonObject = new JSONObject(); +// try { +// jsonObject.put("reason", s); +// } catch (JSONException e) { +// e.printStackTrace(); +// } +// +// PostCommentUtils.postAnswerReportData(context, commentEntity.getId(), answerId, jsonObject.toString(), +// new PostCommentUtils.PostCommentListener() { +// @Override +// public void postSuccess(JSONObject response) { +// Utils.toast(context, "感谢您的举报"); +// } +// +// @Override +// public void postFailed(Throwable error) { +// if (error != null) { +// Utils.toast(context, "举报失败" + error.getMessage()); +// } else { +// Utils.toast(context, "举报失败,请稍候重试"); +// } +// } +// }); +// reportTypeDialog.cancel(); +// }); +// } +// +// reportTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); +// reportTypeDialog.setContentView(container); +// reportTypeDialog.show(); +// } private static void showReportTypeDialog(final CommentEntity commentEntity, final Context context) { final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息", diff --git a/app/src/main/java/com/gh/common/util/EntranceUtils.java b/app/src/main/java/com/gh/common/util/EntranceUtils.java index 0d61d70119..f3a2bf36a7 100644 --- a/app/src/main/java/com/gh/common/util/EntranceUtils.java +++ b/app/src/main/java/com/gh/common/util/EntranceUtils.java @@ -41,6 +41,7 @@ public class EntranceUtils { public static final String KEY_DATA = "data"; public static final String KEY_MESSAGE = "message"; public static final String KEY_TYPE = "type"; + public static final String KEY_LINK = "link"; public static final String KEY_NAME = "name"; public static final String KEY_ENTRANCE = "entrance"; public static final String KEY_TARGET = "target"; diff --git a/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java b/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java index efea8f4fb6..5454a212cb 100644 --- a/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java @@ -5,11 +5,14 @@ import android.content.Intent; import android.os.Bundle; import com.gh.common.util.EntranceUtils; +import com.gh.gamecenter.entity.LinkEntity; import com.gh.gamecenter.entity.MessageEntity; import com.gh.gamecenter.qa.comment.CommentActivity; import com.gh.gamecenter.qa.comment.CommentConversationFragment; import com.halo.assistant.fragment.comment.CommentDetailFragment; +import javax.annotation.Nullable; + /** * Created by khy on 2017/3/22. */ @@ -23,19 +26,28 @@ public class CommentDetailActivity extends NormalActivity { return getTargetIntent(context, CommentDetailActivity.class, CommentDetailFragment.class, args); } - public static Intent getAnswerCommentIntent(Context context, String commentId, String answerId) { + public static Intent getAnswerCommentIntent(Context context, + String commentId, + String answerId, + @Nullable LinkEntity linkEntity) { Bundle args = new Bundle(); args.putString(EntranceUtils.KEY_COMMENTID, commentId); args.putString(EntranceUtils.KEY_ANSWER_ID, answerId); + args.putParcelable(EntranceUtils.KEY_LINK, linkEntity); return getTargetIntent(context, CommentDetailActivity.class, CommentConversationFragment.class, args); } - public static Intent getCommunityArticleCommentIntent(Context context, String articleId, String articleCommentId, String articleCommunityId) { + public static Intent getCommunityArticleCommentIntent(Context context, + String articleId, + String articleCommentId, + String articleCommunityId, + @Nullable LinkEntity linkEntity) { Bundle args = new Bundle(); args.putString(CommentActivity.ARTICLE_ID, articleId); args.putString(EntranceUtils.KEY_ARTICLE_COMMENT_ID, articleCommentId); args.putString(CommentActivity.ARTICLE_COMMUNITY_ID, articleCommunityId); + args.putParcelable(EntranceUtils.KEY_LINK, linkEntity); return getTargetIntent(context, CommentDetailActivity.class, CommentConversationFragment.class, args); } diff --git a/app/src/main/java/com/gh/gamecenter/message/MessageItemViewHolder.java b/app/src/main/java/com/gh/gamecenter/message/MessageItemViewHolder.java index 663b3117b7..bc2c4b11a5 100644 --- a/app/src/main/java/com/gh/gamecenter/message/MessageItemViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/message/MessageItemViewHolder.java @@ -309,7 +309,10 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder if (view.getId() == R.id.message_original) { context.startActivity(AnswerDetailActivity.getIntent(context, entity.getAnswer().getId(), entrance, path)); } else if (view.getId() == R.id.message_item) { - Intent intent = CommentDetailActivity.getAnswerCommentIntent(context, entity.getDialogue().getFrom().getId(), entity.getAnswer().getId()); + Intent intent = CommentDetailActivity.getAnswerCommentIntent(context, + entity.getDialogue().getFrom().getId(), + entity.getAnswer().getId(), + null); context.startActivity(intent); } break; @@ -341,8 +344,11 @@ public class MessageItemViewHolder extends BaseRecyclerViewHolder community = new CommunityEntity(entity.getArticle().getCommunityId(), ""); context.startActivity(ArticleDetailActivity.getIntent(context, community, entity.getArticle().getId(), entrance, path)); } else if (view.getId() == R.id.message_item) { - Intent intent = CommentDetailActivity.getCommunityArticleCommentIntent(context, entity.getArticle().getId(), - entity.getDialogue().getFrom().getId(), entity.getArticle().getCommunityId()); + Intent intent = CommentDetailActivity.getCommunityArticleCommentIntent( + context, entity.getArticle().getId(), + entity.getDialogue().getFrom().getId(), + entity.getArticle().getCommunityId(), + null); context.startActivity(intent); } break; 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 index 8a155cb654..9ab52c9b11 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/comment/CommentConversationFragment.java +++ b/app/src/main/java/com/gh/gamecenter/qa/comment/CommentConversationFragment.java @@ -8,11 +8,14 @@ import android.support.annotation.NonNull; import android.support.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; @@ -20,22 +23,24 @@ import butterknife.BindView; public class CommentConversationFragment extends CommentFragment { @BindView(R.id.answer_comment_content_container) - View mCommentContainer; + 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) { - String entrance; if (!TextUtils.isEmpty(mAnswerId)) { - entrance = "(答案-评论详情-查看对话)"; + mEntrance = "(答案-评论详情-查看对话)"; } else { - entrance = "(文章-评论详情-查看对话)"; + mEntrance = "(文章-评论详情-查看对话)"; } mAdapter = new CommentAdapter(getContext(), mArticleId, mArticleCommunityId, - mAnswerId, false, this, entrance); + mAnswerId, false, this, mEntrance); } return mAdapter; } @@ -48,6 +53,7 @@ public class CommentConversationFragment extends CommentFragment { mArticleId = getArguments().getString(CommentActivity.ARTICLE_ID); mArticleCommentId = getArguments().getString(EntranceUtils.KEY_ARTICLE_COMMENT_ID); mArticleCommunityId = getArguments().getString(CommentActivity.ARTICLE_COMMUNITY_ID); + mLinkEntity = getArguments().getParcelable(EntranceUtils.KEY_LINK); super.onCreate(savedInstanceState); } @@ -55,15 +61,23 @@ public class CommentConversationFragment extends CommentFragment { @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - mCommentContainer.setVisibility(View.GONE); + commentContainer.setVisibility(View.GONE); setNavigationTitle("查看对话"); mListRv.setOnTouchListener((v, event) -> { - if (mCommentContainer.getVisibility() == View.VISIBLE) { - mCommentContainer.setVisibility(View.GONE); + if (commentContainer.getVisibility() == View.VISIBLE) { + commentContainer.setVisibility(View.GONE); } return false; }); + + if (mLinkEntity != null) { + linkTv.setVisibility(View.VISIBLE); + linkTv.setText(mLinkEntity.getTitle()); + linkTv.setOnClickListener(v -> { + DirectUtils.directToLinkPage(getContext(), mLinkEntity, mEntrance, "查看对话"); + }); + } } @Override @@ -79,7 +93,7 @@ public class CommentConversationFragment extends CommentFragment { @Override public void onCommentCallback(CommentEntity entity) { - mCommentContainer.setVisibility(View.VISIBLE); + commentContainer.setVisibility(View.VISIBLE); mCommentEntity = entity; setSoftInput(true); } diff --git a/app/src/main/res/layout/fragment_answer_comment_conversation.xml b/app/src/main/res/layout/fragment_answer_comment_conversation.xml index a5cd640a2e..2df0cd4908 100644 --- a/app/src/main/res/layout/fragment_answer_comment_conversation.xml +++ b/app/src/main/res/layout/fragment_answer_comment_conversation.xml @@ -1,19 +1,45 @@ + android:layout_height="match_parent" + xmlns:tools="http://schemas.android.com/tools"> - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + +