From 5f9e27aa8a1a48e0e2303a905cd379063f2ec7c2 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Mon, 10 Oct 2022 13:38:51 +0800 Subject: [PATCH] =?UTF-8?q?@=E6=B6=88=E6=81=AF=E9=80=BB=E8=BE=91=E8=A1=A5?= =?UTF-8?q?=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/main/res/values-en/strings.xml | 8 ++ common/src/main/res/values/strings.xml | 3 +- .../yunbao/live/adapter/LiveChatAdapter.java | 9 +++ .../yunbao/live/views/LiveRoomViewHolder.java | 75 +++++++++++++++---- .../yunbao/live/views/OlineListActivity.java | 13 +++- 5 files changed, 91 insertions(+), 17 deletions(-) diff --git a/common/src/main/res/values-en/strings.xml b/common/src/main/res/values-en/strings.xml index 62e3fef73..388d67d94 100644 --- a/common/src/main/res/values-en/strings.xml +++ b/common/src/main/res/values-en/strings.xml @@ -901,4 +901,12 @@ Limited ride And limited avatar frame 皇帝 超皇 Please wait... + 滑動設置 + 上下滑動切換直播間 + \@用户昵称\t\t你好啊~ + 在线列表 + 搜索想要@的人 + 在線觀眾 + 觀眾 + 無法@自己 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 2863eacee..01e0203fa 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -912,14 +912,15 @@ 订单查询中 订单无异常 登錄失效,請重新登錄 + 請稍後 滑動設置 上下滑動切換直播間 - 請稍後 \@用户昵称\t\t你好啊~ 在线列表 搜索想要@的人 在線觀眾 觀眾 + 無法@自己 diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java index 5be4c19f3..ce6407f08 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -61,6 +61,8 @@ public class LiveChatAdapter extends RecyclerView.Adapter { private IMLoginModel model; + private int mPosition; + public LiveChatAdapter(Context context) { mContext = context; mList = new ArrayList<>(); @@ -168,6 +170,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } void setData(final LiveChatBean bean, int position) { + itemView.setTag(bean); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.setMargins(0, 0, DpUtil.dp2px(80), 12); @@ -388,6 +391,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { if (bean.getAtUserID().contains(String.valueOf(model.getId()))) { Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.AT_MESSAGE)); + mPosition = size + 1; } } @@ -419,6 +423,11 @@ public class LiveChatAdapter extends RecyclerView.Adapter { mRecyclerView.smoothScrollToPosition(getItemCount()); } } + public void scrollToAt(){ + if (mList.size() > 0) { + mRecyclerView.smoothScrollToPosition(mPosition); + } + } public void clear() { if (mList != null) { diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 8fe686125..fccdebe3d 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -679,6 +679,20 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis ViewClicksAntiShake.clicksAntiShake(newMessage, () -> { chatScrollToBottom(); newMessage.setVisibility(View.GONE); + if (atMessage.getVisibility() == View.VISIBLE) { + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams(); + if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) { + params1.bottomMargin = DpUtil.dp2px(38); + } else { + params1.bottomMargin = DpUtil.dp2px(8); + + } + atMessage.setLayoutParams(params1); + } + }); + ViewClicksAntiShake.clicksAntiShake(atMessage, () -> { + mLiveChatAdapter.scrollToAt(); + atMessage.setVisibility(View.GONE); }); dr_pk_end_gif = (GifImageView) findViewById(R.id.dr_pk_end_gif); msg = (LinearLayout) findViewById(R.id.room_msg); @@ -834,7 +848,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis super.onScrolled(recyclerView, dx, dy); if (mLiveChatAdapter.isSlideToBottom(recyclerView)) { newMessage.setVisibility(View.GONE); - if (atMessage.getVisibility()==View.VISIBLE){ + if (atMessage.getVisibility() == View.VISIBLE) { RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams(); if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) { params1.bottomMargin = DpUtil.dp2px(38); @@ -972,6 +986,21 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis fastMsgRecyclerView.setVisibility(View.GONE); params1.bottomMargin = 0; mChatRecyclerView.setLayoutParams(params1); + RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) newMessage.getLayoutParams(); + RelativeLayout.LayoutParams params3 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams(); + if (newMessage.getVisibility() == View.VISIBLE) { + params2.bottomMargin = DpUtil.dp2px(8); + if (atMessage.getVisibility() == View.VISIBLE) { + params3.bottomMargin = DpUtil.dp2px(38); + atMessage.setLayoutParams(params3); + } + newMessage.setLayoutParams(params2); + } else { + if (atMessage.getVisibility() == View.VISIBLE) { + params3.bottomMargin = DpUtil.dp2px(8); + atMessage.setLayoutParams(params3); + } + } }); // mBanner2.setVisibility(View.GONE); if (fastMsgRecyclerView.getVisibility() == View.GONE) { @@ -3082,6 +3111,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) newMessage.getLayoutParams(); + RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams(); + if (atMessage.getVisibility() == View.VISIBLE) { + + + if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) { + params2.bottomMargin = DpUtil.dp2px(68); + } else { + params1.bottomMargin = DpUtil.dp2px(38); + } + atMessage.setLayoutParams(params2); + } if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) { params1.bottomMargin = DpUtil.dp2px(38); } else { @@ -3094,21 +3134,28 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } public void showAtMessage() { - Locale locale = mContext.getResources().getConfiguration().locale; - String language = locale.getLanguage(); - ImgLoader.display(mContext, TextUtils.equals(language, "zh") ? R.mipmap.emphasis_cn : R.mipmap.emphasis_en, atMessage); - RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams(); - if (newMessage.getVisibility() == View.VISIBLE) { - params1.bottomMargin = DpUtil.dp2px(58); - } else { - if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) { - params1.bottomMargin = DpUtil.dp2px(38); + new Handler().postDelayed(() -> { + Locale locale = mContext.getResources().getConfiguration().locale; + String language = locale.getLanguage(); + ImgLoader.display(mContext, TextUtils.equals(language, "zh") ? R.mipmap.emphasis_cn : R.mipmap.emphasis_en, atMessage); + RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) atMessage.getLayoutParams(); + if (newMessage.getVisibility() == View.VISIBLE) { + if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) { + params1.bottomMargin = DpUtil.dp2px(68); + } else { + params1.bottomMargin = DpUtil.dp2px(38); + } } else { - params1.bottomMargin = DpUtil.dp2px(8); + if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) { + params1.bottomMargin = DpUtil.dp2px(38); + } else { + params1.bottomMargin = DpUtil.dp2px(8); + } } - } - atMessage.setLayoutParams(params1); - atMessage.setVisibility(View.VISIBLE); + atMessage.setLayoutParams(params1); + atMessage.setVisibility(View.VISIBLE); + }, 100); + } } diff --git a/live/src/main/java/com/yunbao/live/views/OlineListActivity.java b/live/src/main/java/com/yunbao/live/views/OlineListActivity.java index 4c41d22d7..bffc3ee67 100644 --- a/live/src/main/java/com/yunbao/live/views/OlineListActivity.java +++ b/live/src/main/java/com/yunbao/live/views/OlineListActivity.java @@ -11,12 +11,15 @@ import androidx.recyclerview.widget.RecyclerView; import com.blankj.utilcode.util.GsonUtils; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.OlineModel; import com.yunbao.common.bean.OlineUserlistModel; import com.yunbao.common.event.LiveInputEvent; import com.yunbao.common.event.OlineEvent; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordsTypeUtil; import com.yunbao.live.R; import com.yunbao.live.adapter.OlineListAdapter; @@ -194,7 +197,13 @@ public class OlineListActivity extends AbsActivity { @Subscribe(threadMode = ThreadMode.MAIN) public void onOlineEvent(OlineEvent event) { - Bus.get().post(new LiveInputEvent().setModel(event.getModel())); - finish(); + IMLoginModel model = IMLoginManager.get(mContext).getUserInfo(); + if (TextUtils.equals(String.valueOf(model.getId()), event.getModel().getId())) { + ToastUtil.show(R.string.cannot_yourself); + } else { + Bus.get().post(new LiveInputEvent().setModel(event.getModel())); + finish(); + } + } }