Commit 98749f01 by Dell

1、修复直播间拉黑和增加部分字段

parent 95814381
...@@ -466,6 +466,10 @@ object Constants { ...@@ -466,6 +466,10 @@ object Constants {
const val LIVE_ROOM_USER_NAME = "live_room_user_name" const val LIVE_ROOM_USER_NAME = "live_room_user_name"
const val USER_LEVEL = "user_level" const val USER_LEVEL = "user_level"
const val MESSAGE_USER_ID = "user_id"
const val MESSAGE_USER_RID = "user_rid"
const val USER_HX_ID = "user_hx_id"
const val GIFT_BEAN = "gift_bean" const val GIFT_BEAN = "gift_bean"
const val SPORT_TYPE= "sport_type" const val SPORT_TYPE= "sport_type"
const val SPORT_NAME= "sport_name" const val SPORT_NAME= "sport_name"
......
...@@ -66,6 +66,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta ...@@ -66,6 +66,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
private var LiveRoomUserName = "" private var LiveRoomUserName = ""
private var roomCover = "" private var roomCover = ""
private var matchId = "" private var matchId = ""
private var liveUserHxId = ""
private var sportType = 0 private var sportType = 0
var historyList = arrayListOf<HistoryMessageEntity>() var historyList = arrayListOf<HistoryMessageEntity>()
override fun loadData() { override fun loadData() {
...@@ -222,6 +223,10 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta ...@@ -222,6 +223,10 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
} }
private fun initIm(userName: String) { private fun initIm(userName: String) {
if (userName.isEmpty()){
initTabLayout(false)
return
}
EMClient.getInstance().login(userName, "123456", object : EMCallBack { EMClient.getInstance().login(userName, "123456", object : EMCallBack {
override fun onSuccess() { override fun onSuccess() {
runOnUiThread { runOnUiThread {
...@@ -259,6 +264,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta ...@@ -259,6 +264,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
roomId, roomId,
notice, notice,
notice2, notice2,
liveUserHxId,
LiveRoomUserName LiveRoomUserName
) )
) )
...@@ -413,7 +419,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta ...@@ -413,7 +419,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
initPlayer(bean?.hotNum.toString(), bean?.roomName ?: "", bean?.liveUrl ?: "") initPlayer(bean?.hotNum.toString(), bean?.roomName ?: "", bean?.liveUrl ?: "")
} }
LiveRoomUserName = bean?.userName ?: "" LiveRoomUserName = bean?.userName ?: ""
liveUserHxId = bean?.huanXinUserId.orEmpty()
if (VersionControl.isShowLive()) { if (VersionControl.isShowLive()) {
initIm(bean?.huanXinUserId ?: "") initIm(bean?.huanXinUserId ?: "")
} else { } else {
......
...@@ -19,6 +19,8 @@ import androidx.annotation.Nullable; ...@@ -19,6 +19,8 @@ import androidx.annotation.Nullable;
import com.hupu.tv.player.app.bean.FakeMessageEntity; import com.hupu.tv.player.app.bean.FakeMessageEntity;
import com.hupu.tv.player.app.ui.activity.LiveActivity; import com.hupu.tv.player.app.ui.activity.LiveActivity;
import com.hupu.tv.player.app.widget.customIm.CustomEaseChatMessageListLayout; import com.hupu.tv.player.app.widget.customIm.CustomEaseChatMessageListLayout;
import com.hyphenate.EMConnectionListener;
import com.hyphenate.EMError;
import com.hyphenate.chat.EMClient; import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMMessage; import com.hyphenate.chat.EMMessage;
import com.hyphenate.easeui.interfaces.EaseChatRoomListener; import com.hyphenate.easeui.interfaces.EaseChatRoomListener;
...@@ -50,11 +52,15 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess ...@@ -50,11 +52,15 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
private Dialog dialog; private Dialog dialog;
private CustomChatPrimaryMenu customChatPrimaryMenu; private CustomChatPrimaryMenu customChatPrimaryMenu;
private CustomChatRoomListener customChatRoomListener; private CustomChatRoomListener customChatRoomListener;
private EMConnectionListener connectionListener;
private String userHxId = "";
@Override @Override
public void initView() { public void initView() {
super.initView(); super.initView();
initConnectListener();
liveUserName = getArguments().getString(Constants.LIVE_ROOM_USER_NAME); liveUserName = getArguments().getString(Constants.LIVE_ROOM_USER_NAME);
userHxId = getArguments().getString(Constants.USER_HX_ID, "");
chatLayout.getChatMessageListLayout().setItemShowType(EaseChatMessageListLayout.ShowType.LEFT); chatLayout.getChatMessageListLayout().setItemShowType(EaseChatMessageListLayout.ShowType.LEFT);
chatLayout.getChatMessageListLayout().setBackground(new ColorDrawable(Color.parseColor("#F4F4F4"))); chatLayout.getChatMessageListLayout().setBackground(new ColorDrawable(Color.parseColor("#F4F4F4")));
customChatPrimaryMenu = new CustomChatPrimaryMenu(getContext()); customChatPrimaryMenu = new CustomChatPrimaryMenu(getContext());
...@@ -66,6 +72,23 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess ...@@ -66,6 +72,23 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
setShowChatPrimaryMenu(); setShowChatPrimaryMenu();
} }
private void initConnectListener() {
connectionListener = new EMConnectionListener() {
@Override
public void onConnected() {
}
@Override
public void onDisconnected(int errorCode) {
if (errorCode == EMError.USER_KICKED_BY_OTHER_DEVICE) {
customChatPrimaryMenu.setCanSend(false);
}
}
};
EMClient.getInstance().addConnectionListener(connectionListener);
}
public void setOnMemberJoinListener(OnMemberJoinListener onMemberJoinListener) { public void setOnMemberJoinListener(OnMemberJoinListener onMemberJoinListener) {
this.onMemberJoinListener = onMemberJoinListener; this.onMemberJoinListener = onMemberJoinListener;
} }
...@@ -86,6 +109,8 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess ...@@ -86,6 +109,8 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
LiveUserBean liveUserBean = SPUtil.Companion.getSerializableObject(Constants.LIVE_USER_BEAN); LiveUserBean liveUserBean = SPUtil.Companion.getSerializableObject(Constants.LIVE_USER_BEAN);
if (liveUserBean != null) { if (liveUserBean != null) {
message.setAttribute(Constants.USER_NICK, liveUserBean.getUserName()); message.setAttribute(Constants.USER_NICK, liveUserBean.getUserName());
message.setAttribute(Constants.MESSAGE_USER_RID, liveUserBean.getId());
message.setAttribute(Constants.MESSAGE_USER_ID, userHxId);
message.setAttribute(Constants.USER_LEVEL, liveUserBean.getLevel()); message.setAttribute(Constants.USER_LEVEL, liveUserBean.getLevel());
} }
} }
...@@ -410,6 +435,7 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess ...@@ -410,6 +435,7 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
chatMessageListLayout = null; chatMessageListLayout = null;
} }
EMClient.getInstance().removeConnectionListener(connectionListener);
if (chatLayout != null) { if (chatLayout != null) {
chatLayout = null; chatLayout = null;
} }
......
...@@ -43,9 +43,11 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres ...@@ -43,9 +43,11 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres
conversationId: String, conversationId: String,
notice: String, notice: String,
notice2: String, notice2: String,
userHxId:String,
userName: String userName: String
): LiveConversationFragment { ): LiveConversationFragment {
val args = Bundle() val args = Bundle()
args.putString(Constants.USER_HX_ID, userHxId)
args.putString(EaseConstant.EXTRA_CONVERSATION_ID, conversationId) args.putString(EaseConstant.EXTRA_CONVERSATION_ID, conversationId)
args.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM) args.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM)
args.putBoolean(EaseConstant.EXTRA_IS_ROAM, true) args.putBoolean(EaseConstant.EXTRA_IS_ROAM, true)
...@@ -114,6 +116,7 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres ...@@ -114,6 +116,7 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres
private fun initChatFragment() { private fun initChatFragment() {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(Constants.USER_HX_ID, arguments?.getString(Constants.USER_HX_ID))
bundle.putString(EaseConstant.EXTRA_CONVERSATION_ID, arguments?.getString(EaseConstant.EXTRA_CONVERSATION_ID)) bundle.putString(EaseConstant.EXTRA_CONVERSATION_ID, arguments?.getString(EaseConstant.EXTRA_CONVERSATION_ID))
bundle.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM) bundle.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM)
bundle.putBoolean(EaseConstant.EXTRA_IS_ROAM, true) bundle.putBoolean(EaseConstant.EXTRA_IS_ROAM, true)
......
...@@ -18,6 +18,7 @@ object VersionControl { ...@@ -18,6 +18,7 @@ object VersionControl {
private const val VIVO = "qj_vivo_01" private const val VIVO = "qj_vivo_01"
private const val HUAWEI = "qj_huawei_01" private const val HUAWEI = "qj_huawei_01"
private const val OPPO = "qj_oppo_01" private const val OPPO = "qj_oppo_01"
private const val XIAOMI = "qj_xiaomi_01"
fun isShowLive(): Boolean { fun isShowLive(): Boolean {
...@@ -26,7 +27,7 @@ object VersionControl { ...@@ -26,7 +27,7 @@ object VersionControl {
fun saveConfig(showConfig: Boolean) { fun saveConfig(showConfig: Boolean) {
when (BuildConfig.FLAVOR) { when (BuildConfig.FLAVOR) {
BAIDU, VIVO, HUAWEI, OPPO -> SPUtil.put(Constants.SHOW_LIVE_CONFIG, showConfig) BAIDU, VIVO, HUAWEI, OPPO, XIAOMI -> SPUtil.put(Constants.SHOW_LIVE_CONFIG, showConfig)
else -> SPUtil.put(Constants.SHOW_LIVE_CONFIG, true) else -> SPUtil.put(Constants.SHOW_LIVE_CONFIG, true)
} }
} }
......
...@@ -24,6 +24,7 @@ import android.widget.RelativeLayout; ...@@ -24,6 +24,7 @@ import android.widget.RelativeLayout;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.blankj.utilcode.util.LogUtils;
import com.example.zhouwei.library.CustomPopWindow; import com.example.zhouwei.library.CustomPopWindow;
import com.hyphenate.easeui.modules.chat.EaseInputEditText; import com.hyphenate.easeui.modules.chat.EaseInputEditText;
import com.hyphenate.easeui.modules.chat.EaseInputMenuStyle; import com.hyphenate.easeui.modules.chat.EaseInputMenuStyle;
...@@ -37,6 +38,8 @@ import com.hupu.tv.player.app.utils.DialogUtils; ...@@ -37,6 +38,8 @@ import com.hupu.tv.player.app.utils.DialogUtils;
import com.softgarden.baselibrary.utils.ToastUtil; import com.softgarden.baselibrary.utils.ToastUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimaryMenu, View.OnClickListener, EaseInputEditText.OnEditTextChangeListener, TextWatcher { public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimaryMenu, View.OnClickListener, EaseInputEditText.OnEditTextChangeListener, TextWatcher {
private LinearLayout rlBottom; private LinearLayout rlBottom;
...@@ -51,7 +54,7 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar ...@@ -51,7 +54,7 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar
private CheckBox buttonMore; private CheckBox buttonMore;
private Button buttonSend; private Button buttonSend;
private OnSendMessageListener sendMessageListener; private OnSendMessageListener sendMessageListener;
private boolean isCanSend =true;
private EaseChatPrimaryMenuListener listener; private EaseChatPrimaryMenuListener listener;
private EaseInputMenuStyle menuType = EaseInputMenuStyle.All;//菜单展示形式 private EaseInputMenuStyle menuType = EaseInputMenuStyle.All;//菜单展示形式
protected InputMethodManager inputManager; protected InputMethodManager inputManager;
...@@ -76,6 +79,9 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar ...@@ -76,6 +79,9 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar
public void setOnSendMessageListener(OnSendMessageListener onSendMessageListener) { public void setOnSendMessageListener(OnSendMessageListener onSendMessageListener) {
sendMessageListener = onSendMessageListener; sendMessageListener = onSendMessageListener;
} }
public void setCanSend(boolean canSend){
isCanSend = canSend;
}
private void initViews() { private void initViews() {
rlBottom = findViewById(R.id.rl_bottom); rlBottom = findViewById(R.id.rl_bottom);
...@@ -217,6 +223,38 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar ...@@ -217,6 +223,38 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar
} }
} }
private void sendMessage(String message){
if (message.isEmpty()){
ToastUtil.Companion.s("请输入内容");
return;
}
if (!isCanSend){
ToastUtil.Companion.s("您已被禁言,如有疑问请联系客服");
return;
}
// if (checkSend(message)){
// ToastUtil.Companion.s("敏感词汇不能发送,请检查后重新发送");
// return;
// }
if (listener != null) {
editText.setText("");
listener.onSendBtnClicked(message);
if (sendMessageListener != null) {
sendMessageListener.send(message);
}
}
}
// private boolean checkSend(String content){
// String regex = (String) SPUtil.Companion.get(Constants.CONFIG_VALUE, "");
// Pattern pattern = Pattern.compile(regex);
// Matcher matcher = pattern.matcher(content);
// boolean matches =matcher.find();
// LogUtils.i("regex = "+regex + "input content = "+content+ "matches = "+matches );
// return matches;
// }
@Override @Override
public void showMoreStatus() { public void showMoreStatus() {
if (buttonMore.isChecked()) { if (buttonMore.isChecked()) {
...@@ -281,19 +319,7 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar ...@@ -281,19 +319,7 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar
public void onClick(View v) { public void onClick(View v) {
int id = v.getId(); int id = v.getId();
if (id == R.id.btn_send) {//发送 if (id == R.id.btn_send) {//发送
if (editText.getText().toString().isEmpty()){ sendMessage(editText.getText().toString());
ToastUtil.Companion.s("请输入内容");
return;
}
if (listener != null) {
String s = editText.getText().toString();
editText.setText("");
listener.onSendBtnClicked(s);
if (sendMessageListener != null) {
sendMessageListener.send(s);
}
}
} else if (id == R.id.btn_set_mode_voice) {//切换到语音模式 } else if (id == R.id.btn_set_mode_voice) {//切换到语音模式
// showVoiceStatus(); // showVoiceStatus();
showCustomPopWindow(); showCustomPopWindow();
...@@ -362,12 +388,7 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar ...@@ -362,12 +388,7 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar
@Override @Override
public void onClickKeyboardSendBtn(String content) { public void onClickKeyboardSendBtn(String content) {
if (listener != null) { sendMessage(content);
listener.onSendBtnClicked(content);
if (sendMessageListener != null) {
sendMessageListener.send(content);
}
}
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment