diff --git a/common/src/main/java/com/yunbao/common/views/weight/AtTextWatcher.java b/common/src/main/java/com/yunbao/common/views/weight/AtTextWatcher.java
index b09afcd98..ebf86475f 100644
--- a/common/src/main/java/com/yunbao/common/views/weight/AtTextWatcher.java
+++ b/common/src/main/java/com/yunbao/common/views/weight/AtTextWatcher.java
@@ -112,4 +112,28 @@ public class AtTextWatcher implements TextWatcher {
}
}
+ private String atUserID, atUserName;
+
+ public String getAtUserID() {
+ StringBuffer stringBuffer = new StringBuffer();
+ for (String userID : spanMap.keySet()) {
+ stringBuffer.append(userID);
+ stringBuffer.append(",");
+ }
+ return stringBuffer.toString();
+ }
+
+ public String getAtUserName() {
+ StringBuffer stringBuffer = new StringBuffer();
+ for (String userID : spanMap.keySet()) {
+ OlineUserlistModel model = spanMap.get(userID);
+ stringBuffer.append(model.getUserNicename());
+ stringBuffer.append(",");
+ }
+ return stringBuffer.toString();
+ }
+
+ public void clearMsg() {
+ spanMap.clear();
+ }
}
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java
index 1ec757e10..3ad34edc7 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java
@@ -938,7 +938,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
/**
* 发 聊天 消息
*/
- public void sendChatMessage(String content) {
+ public void sendChatMessage(String content, String atUserID, String atUserName) {
if (!mIsAnchor) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u != null && u.getLevel() < mChatLevel) {
@@ -947,7 +947,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
}
}
int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE;
- SocketRyChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType);
+ SocketRyChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType,atUserID,atUserName);
}
/**
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
index a09e91e4f..667b116e2 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
@@ -833,6 +833,9 @@ public class LiveAudienceActivity extends LiveActivity {
case NEW_MESSAGE_REMINDER:
manager.showNewMessage();
break;
+ case AT_MESSAGE:
+ manager.showAtMessage();
+ break;
}
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 336a4bb4d..5be4c19f3 100644
--- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
+++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
@@ -24,8 +24,10 @@ import androidx.recyclerview.widget.RecyclerView;
import com.makeramen.roundedimageview.RoundedImageView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
+import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.interfaces.OnItemClickListener;
+import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.live.R;
@@ -57,10 +59,13 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
private RecyclerView mRecyclerView;
private LinearLayoutManager mLayoutManager;
+ private IMLoginModel model;
+
public LiveChatAdapter(Context context) {
mContext = context;
mList = new ArrayList<>();
mInflater = LayoutInflater.from(context);
+ model = IMLoginManager.get(context).getUserInfo();
mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -289,7 +294,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
} else if (bean.getType() == LiveChatBean.SYSTEM) {
boolean isContains = false;
for (LiveChatBean model : mList) {
- if (!TextUtils.isEmpty(model.getContent()) && (model.getContent().contains("堅決維護青少年群體精神文明健康")||model.getContent().contains("click to register if you like. pdlive conducts"))) {
+ if (!TextUtils.isEmpty(model.getContent()) && (model.getContent().contains("堅決維護青少年群體精神文明健康") || model.getContent().contains("click to register if you like. pdlive conducts"))) {
isContains = true;
}
}
@@ -374,13 +379,16 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
mList.add(beanNull);
notifyItemChanged(size + 1);
- if (isSlideToBottom(mRecyclerView)){
+ if (isSlideToBottom(mRecyclerView)) {
mRecyclerView.scrollToPosition(size + 1);
- }else {
+ } else {
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.NEW_MESSAGE_REMINDER));
}
-
+ if (bean.getAtUserID().contains(String.valueOf(model.getId()))) {
+ Bus.get().post(new LiveAudienceEvent()
+ .setType(LiveAudienceEvent.LiveAudienceType.AT_MESSAGE));
+ }
}
/**
@@ -389,7 +397,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
* @param recyclerView
* @return
*/
- public boolean isSlideToBottom(RecyclerView recyclerView) {
+ public boolean isSlideToBottom(RecyclerView recyclerView) {
if (recyclerView == null) return false;
if (recyclerView.computeVerticalScrollExtent() + recyclerView.computeVerticalScrollOffset()
>= recyclerView.computeVerticalScrollRange())
diff --git a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java
index 044c84de6..c6b55e3a6 100644
--- a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java
+++ b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java
@@ -58,6 +58,30 @@ public class LiveChatBean {
//超皇字体颜色
@SerializedName("contentColor")
private String contentColor = "";
+ //@名字
+ @SerializedName("atUserName")
+ private String atUserName = "";
+ //@ID
+ @SerializedName("atUserID")
+ private String atUserID = "";
+
+ public String getAtUserName() {
+ return atUserName;
+ }
+
+ public LiveChatBean setAtUserName(String atUserName) {
+ this.atUserName = atUserName;
+ return this;
+ }
+
+ public String getAtUserID() {
+ return atUserID;
+ }
+
+ public LiveChatBean setAtUserID(String atUserID) {
+ this.atUserID = atUserID;
+ return this;
+ }
public String getStartColor() {
return startColor;
diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java
index 6a9fca469..6d79a9ab0 100644
--- a/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java
+++ b/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java
@@ -76,6 +76,7 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
private long trumpetNum;//喇叭数量
private String mLiveUid;//主播ID
private AtTextWatcher atTextWatcher;
+ private String atUserID = null, atUserName = null;
@Override
protected int getLayoutId() {
@@ -235,7 +236,9 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O
((LiveActivity) mContext).sendDanmuMessage(content);
break;
case GENERALMESSAGE:
- ((LiveActivity) mContext).sendChatMessage(content);
+ ((LiveActivity) mContext).sendChatMessage(content, atTextWatcher.getAtUserID(),atTextWatcher.getAtUserName() );
+ atTextWatcher.clearMsg();
+ dismiss();
break;
}
mInput.setText("");
diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
index f2b80de9a..4aa8a9edd 100644
--- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
+++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
@@ -132,7 +132,8 @@ public class LiveAudienceEvent extends BaseModel {
TRUMPET_NOTIFY(20, "全服喇叭"),
RECOMMEND_CARD_NOTIFY(21, "贵族推荐通知"),
SLIDE_SETTINGS(22, "滑動設置"),
- NEW_MESSAGE_REMINDER(23, "新消息提醒")
+ NEW_MESSAGE_REMINDER(23, "新消息提醒"),
+ AT_MESSAGE(24, "@消息")
;
private int type;
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java
index 65a9848fa..fa35d42f5 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java
@@ -1,5 +1,8 @@
package com.yunbao.live.socket;
+import static com.yunbao.common.CommonAppContext.logger;
+import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
+
import android.util.Log;
import com.adjust.sdk.Adjust;
@@ -24,9 +27,6 @@ import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.message.TextMessage;
-import static com.yunbao.common.CommonAppContext.logger;
-import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
-
/**
* Created by cxf on 2018/10/9.
* 直播间发言
@@ -80,7 +80,7 @@ public class SocketRyChatUtil {
/**
* 发言
*/
- public static void sendChatMessage(String mLiveUid, String content, boolean isAnchor, int userType, int guardType) {
+ public static void sendChatMessage(String mLiveUid, String content, boolean isAnchor, int userType, int guardType, String atUserID, String atUserName) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
IMLoginModel model = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
if (u == null) {
@@ -112,7 +112,8 @@ public class SocketRyChatUtil {
.param("contentColor", String.valueOf(model.getContentColor()))
.param("startColor", String.valueOf(model.getStartColor()))
.param("endColor", String.valueOf(model.getEndColor()))
- ;
+ .param("atUserName", String.valueOf(atUserName))
+ .param("atUserID", String.valueOf(atUserID));
msg.create();
String targetId = "g" + mLiveUid;
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
index 538b00ebf..a4c851cc4 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
@@ -1,5 +1,13 @@
package com.yunbao.live.socket;
+import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
+import static com.blankj.utilcode.util.ViewUtils.runOnUiThread;
+import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK;
+import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.leaveDRRoom;
+import static com.yunbao.live.views.LivePushRyViewHolder.dr_pk_view;
+import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom;
+import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot;
+
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
@@ -54,14 +62,6 @@ import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.chatroom.base.RongChatRoomClient;
-import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
-import static com.blankj.utilcode.util.ViewUtils.runOnUiThread;
-import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK;
-import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.leaveDRRoom;
-import static com.yunbao.live.views.LivePushRyViewHolder.dr_pk_view;
-import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom;
-import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot;
-
public class SocketRyClient {
private static final String TAG = "socket";
@@ -609,6 +609,8 @@ public class SocketRyClient {
chatBean.setStartColor(map.getString("startColor"));//昵称开始颜色
chatBean.setEndColor(map.getString("endColor"));//昵称结束颜色
chatBean.setContentColor(map.getString("contentColor"));//文字内容颜色
+ chatBean.setAtUserName(map.getString("atUserName"));//@名字
+ chatBean.setAtUserID(map.getString("atUserID"));//@ID
if (!map.getString("guard_type").equals("undefined")) {
chatBean.setGuardType(map.getIntValue("guard_type"));
}
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 a22e75200..8fe686125 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
@@ -206,7 +206,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public static String mNameText;
public static String mAvatarUrl;
public static FrameLayout ft_hot_add;
- public static ImageView img_hot_gif, newMessage;
+ public static ImageView img_hot_gif, newMessage, atMessage;
//多人PK
static TextView time;
@@ -673,6 +673,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mic_ico = (ImageView) findViewById(R.id.mic_ico);
newMessage = (ImageView) findViewById(R.id.new_message);
+ atMessage = (ImageView) findViewById(R.id.at_message);
mic_ico1 = (RoundedImageView) findViewById(R.id.mic_ico1);
mic_ico2 = (RoundedImageView) findViewById(R.id.mic_ico2);
ViewClicksAntiShake.clicksAntiShake(newMessage, () -> {
@@ -808,7 +809,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mLiveChatAdapter.removetItem(bean);
} else if (bean.getType() == -2) {
mLiveChatAdapter.removetItem(bean);
- ((LiveActivity) mContext).sendChatMessage("Hi~");
+ ((LiveActivity) mContext).sendChatMessage("Hi~", null, null);
} else if (bean.getType() == -5) {
String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Turntable&a=tricky";
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
@@ -833,6 +834,17 @@ 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){
+ 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);
+ }
+
}
}
});
@@ -956,7 +968,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
fastMsgRecyclerView.setAdapter(fastMessageRecyclerViewAdapter);
fastMessageRecyclerViewAdapter.setMessageListener(msg -> {
//点击的消息发送出去
- ((LiveActivity) mContext).sendChatMessage(msg);
+ ((LiveActivity) mContext).sendChatMessage(msg, null, null);
fastMsgRecyclerView.setVisibility(View.GONE);
params1.bottomMargin = 0;
mChatRecyclerView.setLayoutParams(params1);
@@ -3059,6 +3071,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
});
}
+
/**
* 展示新消息提示
*/
@@ -3066,6 +3079,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
Locale locale = mContext.getResources().getConfiguration().locale;
String language = locale.getLanguage();
ImgLoader.display(mContext, TextUtils.equals(language, "zh") ? R.mipmap.new_message_cn : R.mipmap.new_message_en, newMessage);
+
+
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) newMessage.getLayoutParams();
if (fastMsgRecyclerView.getVisibility() == View.VISIBLE) {
params1.bottomMargin = DpUtil.dp2px(38);
@@ -3075,5 +3090,25 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
newMessage.setLayoutParams(params1);
newMessage.setVisibility(View.VISIBLE);
+
+ }
+
+ 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);
+ } else {
+ params1.bottomMargin = DpUtil.dp2px(8);
+ }
+ }
+
+ atMessage.setLayoutParams(params1);
+ atMessage.setVisibility(View.VISIBLE);
}
}
diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
index 1066b35b3..358f220b2 100644
--- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
+++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
@@ -1531,7 +1531,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
*/
public void showNewMessage() {
if (mLiveRoomViewHolder != null) {
- mLiveRoomViewHolder.showNewMessage();
+ mLiveRoomViewHolder.showNewMessage( );
+ }
+ }
+ public void showAtMessage(){
+ if (mLiveRoomViewHolder!=null){
+ mLiveRoomViewHolder.showAtMessage();
}
}
}
diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml
index a422be806..45c9d118c 100644
--- a/live/src/main/res/layout/view_live_room.xml
+++ b/live/src/main/res/layout/view_live_room.xml
@@ -1995,6 +1995,8 @@
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
+
+
+
+