@消息逻辑补充

This commit is contained in:
18401019693 2022-10-10 13:38:51 +08:00
parent 06bc518372
commit 5f9e27aa8a
5 changed files with 91 additions and 17 deletions

View File

@ -901,4 +901,12 @@ Limited ride And limited avatar frame</string>
<string name="emperor">皇帝</string>
<string name="better_emperor">超皇</string>
<string name="login_wait">Please wait...</string>
<string name="slide_settings">滑動設置</string>
<string name="up_slide_settings">上下滑動切換直播間</string>
<string name="live_say_something_a">\@用户昵称\t\t你好啊</string>
<string name="oline_list">在线列表</string>
<string name="search_want">搜索想要@的人</string>
<string name="online_audience">在線觀眾</string>
<string name="audience">觀眾</string>
<string name="cannot_yourself">無法@自己</string>
</resources>

View File

@ -912,14 +912,15 @@
<string name="order_query">订单查询中</string>
<string name="order_query_success">订单无异常</string>
<string name="login_invalid">登錄失效,請重新登錄</string>
<string name="login_wait">請稍後</string>
<string name="slide_settings">滑動設置</string>
<string name="up_slide_settings">上下滑動切換直播間</string>
<string name="login_wait">請稍後</string>
<string name="live_say_something_a">\@用户昵称\t\t你好啊</string>
<string name="oline_list">在线列表</string>
<string name="search_want">搜索想要@的人</string>
<string name="online_audience">在線觀眾</string>
<string name="audience">觀眾</string>
<string name="cannot_yourself">無法@自己</string>
</resources>

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -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();
}
}
}