From 4fef613390febacaf6e3682f55f483589f3010fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E4=B9=85?= Date: Mon, 22 Aug 2022 16:44:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90=E5=85=89=E7=8E=AF=E5=8A=A9?= =?UTF-8?q?=E6=89=8BV5.13.0=E3=80=91=E8=AF=84=E8=AE=BA=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20IP=E5=B1=9E=E5=9C=B0=E5=B1=95=E7=A4=BA(0822?= =?UTF-8?q?=E6=B5=8B=E8=AF=953,4)=20https://git.shanqu.cc/pm/halo/halo-app?= =?UTF-8?q?-issues/-/issues/2008?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/CommentDetailAdapter.java | 3 ++ .../adapter/MessageDetailAdapter.java | 12 +++++-- .../message/MessageDetailFragment.java | 34 ++++++++----------- 3 files changed, 28 insertions(+), 21 deletions(-) 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 edc67d0f5a..51860f2e01 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java @@ -154,6 +154,9 @@ public class CommentDetailAdapter extends BaseRecyclerAdapter { CommentUtils.setCommentUserView(mContext, holder, commentEntity); CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.getTime()); + if (commentEntity.getSource() != null && !commentEntity.getSource().getRegion().isEmpty()) { + holder.commentTimeTv.setText(holder.commentTimeTv.getText() + " · " + commentEntity.getSource().getRegion()); + } TextHelper.highlightTextThatIsWrappedInsideWrapperByDefault(holder.commentContentTv, commentEntity.getContent()); ArticleCommentParent parent = commentEntity.getParent(); 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 34159b963b..fdb133d208 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java @@ -131,20 +131,28 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter { mHotCommentList.addAll(response); notifyDataSetChanged(); } - addNormalComment(); // 考虑到断网刷新问题 + addNormalComment(true); // 考虑到断网刷新问题 } @Override public void onFailure(HttpException e) { - addNormalComment(); + addNormalComment(true); } }); } public void addNormalComment() { + addNormalComment(false); + } + + public void addNormalComment(boolean isRefresh) { if (isLoading) { return; } + if (isRefresh){ + mNormalCommentList.clear(); + mPage = 1; + } isLoading = true; RetrofitManager.getInstance().getApi().getComment(mConcernEntity.getId(), 10, mPage, Utils.getTime(mContext)) .subscribeOn(Schedulers.io()) diff --git a/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java b/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java index 017ea5aaa5..aad78b4476 100644 --- a/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java +++ b/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java @@ -21,33 +21,32 @@ import androidx.recyclerview.widget.RecyclerView; import com.gh.common.constant.Config; import com.gh.common.util.CheckLoginUtils; import com.gh.common.util.DialogUtils; -import com.gh.gamecenter.common.callback.ConfirmListener; -import com.gh.gamecenter.core.utils.DisplayUtils; -import com.gh.gamecenter.common.constant.EntranceConsts; import com.gh.common.util.ErrorHelper; -import com.gh.gamecenter.core.utils.GsonUtils; -import com.gh.gamecenter.core.utils.KeyboardHeightObserver; -import com.gh.gamecenter.core.utils.KeyboardHeightProvider; import com.gh.common.util.PostCommentUtils; -import com.gh.gamecenter.common.utils.TextHelper; -import com.gh.gamecenter.common.utils.TimestampUtils; -import com.gh.gamecenter.core.utils.UrlFilterUtils; import com.gh.gamecenter.MessageDetailActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.adapter.MessageDetailAdapter; import com.gh.gamecenter.adapter.OnCommentCallBackListener; +import com.gh.gamecenter.common.base.fragment.ToolbarFragment; +import com.gh.gamecenter.common.constant.EntranceConsts; +import com.gh.gamecenter.common.eventbus.EBReuse; +import com.gh.gamecenter.common.retrofit.OkHttpCache; +import com.gh.gamecenter.common.retrofit.Response; +import com.gh.gamecenter.common.utils.TextHelper; +import com.gh.gamecenter.common.utils.TimestampUtils; +import com.gh.gamecenter.core.utils.DisplayUtils; +import com.gh.gamecenter.core.utils.GsonUtils; +import com.gh.gamecenter.core.utils.KeyboardHeightObserver; +import com.gh.gamecenter.core.utils.KeyboardHeightProvider; +import com.gh.gamecenter.core.utils.UrlFilterUtils; import com.gh.gamecenter.databinding.FragmentMessageDetailBinding; import com.gh.gamecenter.entity.CommentEntity; import com.gh.gamecenter.entity.CommentnumEntity; import com.gh.gamecenter.entity.ConcernEntity; -import com.gh.gamecenter.login.entity.UserInfoEntity; import com.gh.gamecenter.entity.ViewsEntity; -import com.gh.gamecenter.common.eventbus.EBReuse; -import com.gh.gamecenter.manager.CommentManager; +import com.gh.gamecenter.login.entity.UserInfoEntity; import com.gh.gamecenter.login.user.UserManager; -import com.gh.gamecenter.common.base.fragment.ToolbarFragment; -import com.gh.gamecenter.common.retrofit.OkHttpCache; -import com.gh.gamecenter.common.retrofit.Response; +import com.gh.gamecenter.manager.CommentManager; import com.gh.gamecenter.retrofit.RetrofitManager; import com.halo.assistant.HaloApp; import com.lightgame.listeners.OnBackPressedListener; @@ -363,10 +362,7 @@ public class MessageDetailFragment extends ToolbarFragment implements OnCommentC cacheObject.put("parent", cacheParent); } - CommentEntity commentEntity = GsonUtils.fromJson(cacheObject.toString(), CommentEntity.class); - if (mConcernEntity != null) { - adapter.addNormalComment(commentEntity); - } + adapter.addNormalComment(true); modifyNewsCommentOkhttpCache(adapter.findTheLastPriorComment(), cacheObject, newsId); } catch (JSONException e) {