From 4e6b8bf6b37e04275a7ef465f6b417d4be835dbc Mon Sep 17 00:00:00 2001 From: kehaoyuan Date: Mon, 6 May 2019 15:39:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B8=B8=E6=88=8F=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E5=9B=9E=E5=A4=8D=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gh/common/util/CommentUtils.java | 129 ------------------ .../java/com/gh/common/util/Extensions.kt | 6 + .../gh/gamecenter/entity/RatingReplyEntity.kt | 6 +- .../gamedetail/rating/RatingReplyActivity.kt | 64 ++++++++- .../gamedetail/rating/RatingReplyAdapter.kt | 19 ++- .../gamedetail/rating/RatingReplyViewModel.kt | 7 + .../gamedetail/rating/RatingViewModel.kt | 1 + .../main/java/com/halo/assistant/HaloApp.java | 2 +- app/src/main/res/layout/rating_reply_item.xml | 7 +- app/src/main/res/values/strings.xml | 15 +- 10 files changed, 110 insertions(+), 146 deletions(-) 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 e734ff9aca..85933b2fe7 100644 --- a/app/src/main/java/com/gh/common/util/CommentUtils.java +++ b/app/src/main/java/com/gh/common/util/CommentUtils.java @@ -269,135 +269,6 @@ 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) { -// -// 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(); -// } - -// 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/Extensions.kt b/app/src/main/java/com/gh/common/util/Extensions.kt index 73f4b49ae3..b7ad859b1b 100644 --- a/app/src/main/java/com/gh/common/util/Extensions.kt +++ b/app/src/main/java/com/gh/common/util/Extensions.kt @@ -5,6 +5,8 @@ import android.content.Context import android.support.v4.app.Fragment import android.support.v4.app.FragmentActivity import android.support.v4.view.ViewPager +import android.text.Html +import android.text.Spanned import android.view.View import com.google.gson.reflect.TypeToken @@ -106,4 +108,8 @@ fun debounceActionWithInterval(id: Int, interval: Long = 300, action: (() -> Uni fun View.debounceActionWithInterval(interval: Long = 300, action: (() -> Unit)? = null) { debounceActionWithInterval(this.id, interval, action) +} + +fun String.fromHtml(): Spanned { + return Html.fromHtml(this) } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/entity/RatingReplyEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/RatingReplyEntity.kt index d78b91eb15..27d8fea594 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/RatingReplyEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/RatingReplyEntity.kt @@ -8,4 +8,8 @@ class RatingReplyEntity(@SerializedName("_id") val time: Long, val me: MeEntity, val user: UserEntity, - val vote: Int) \ No newline at end of file + val vote: Int, + val parent: Parent?) { + + class Parent(val user: UserEntity) +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyActivity.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyActivity.kt index 418d3b55b1..df9c7c3acf 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyActivity.kt @@ -5,29 +5,40 @@ import android.arch.lifecycle.ViewModelProviders import android.content.Context import android.content.Intent import android.os.Bundle +import android.support.v4.content.ContextCompat import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.RecyclerView +import android.text.Editable +import android.text.TextWatcher import android.view.View +import android.widget.Button import android.widget.EditText import butterknife.OnClick import com.gh.base.BaseActivity +import com.gh.base.fragment.WaitingDialogFragment import com.gh.common.util.EntranceUtils import com.gh.gamecenter.R import com.gh.gamecenter.entity.GameEntity import com.gh.gamecenter.entity.RatingComment +import com.gh.gamecenter.entity.RatingReplyEntity import com.gh.gamecenter.mvvm.Status +import com.gh.gamecenter.qa.questions.edit.manager.HistoryDetailActivity +import com.lightgame.utils.Util_System_Keyboard import com.lightgame.utils.Utils import kotterknife.bindView class RatingReplyActivity : BaseActivity() { private val mRecyclerView by bindView(R.id.rating_reply_list) - private val mPostReplyButton by bindView(R.id.answer_comment_send_btn) + private val mPostReplyButton by bindView