Commit 98749f01 by Dell

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

parent 95814381
......@@ -466,6 +466,10 @@ object Constants {
const val LIVE_ROOM_USER_NAME = "live_room_user_name"
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 SPORT_TYPE= "sport_type"
const val SPORT_NAME= "sport_name"
......
......@@ -66,6 +66,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
private var LiveRoomUserName = ""
private var roomCover = ""
private var matchId = ""
private var liveUserHxId = ""
private var sportType = 0
var historyList = arrayListOf<HistoryMessageEntity>()
override fun loadData() {
......@@ -222,6 +223,10 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
}
private fun initIm(userName: String) {
if (userName.isEmpty()){
initTabLayout(false)
return
}
EMClient.getInstance().login(userName, "123456", object : EMCallBack {
override fun onSuccess() {
runOnUiThread {
......@@ -259,6 +264,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
roomId,
notice,
notice2,
liveUserHxId,
LiveRoomUserName
)
)
......@@ -413,7 +419,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
initPlayer(bean?.hotNum.toString(), bean?.roomName ?: "", bean?.liveUrl ?: "")
}
LiveRoomUserName = bean?.userName ?: ""
liveUserHxId = bean?.huanXinUserId.orEmpty()
if (VersionControl.isShowLive()) {
initIm(bean?.huanXinUserId ?: "")
} else {
......
......@@ -19,6 +19,8 @@ import androidx.annotation.Nullable;
import com.hupu.tv.player.app.bean.FakeMessageEntity;
import com.hupu.tv.player.app.ui.activity.LiveActivity;
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.EMMessage;
import com.hyphenate.easeui.interfaces.EaseChatRoomListener;
......@@ -50,11 +52,15 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
private Dialog dialog;
private CustomChatPrimaryMenu customChatPrimaryMenu;
private CustomChatRoomListener customChatRoomListener;
private EMConnectionListener connectionListener;
private String userHxId = "";
@Override
public void initView() {
super.initView();
initConnectListener();
liveUserName = getArguments().getString(Constants.LIVE_ROOM_USER_NAME);
userHxId = getArguments().getString(Constants.USER_HX_ID, "");
chatLayout.getChatMessageListLayout().setItemShowType(EaseChatMessageListLayout.ShowType.LEFT);
chatLayout.getChatMessageListLayout().setBackground(new ColorDrawable(Color.parseColor("#F4F4F4")));
customChatPrimaryMenu = new CustomChatPrimaryMenu(getContext());
......@@ -66,6 +72,23 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
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) {
this.onMemberJoinListener = onMemberJoinListener;
}
......@@ -86,6 +109,8 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
LiveUserBean liveUserBean = SPUtil.Companion.getSerializableObject(Constants.LIVE_USER_BEAN);
if (liveUserBean != null) {
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());
}
}
......@@ -410,6 +435,7 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
chatMessageListLayout = null;
}
EMClient.getInstance().removeConnectionListener(connectionListener);
if (chatLayout != null) {
chatLayout = null;
}
......
......@@ -43,9 +43,11 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres
conversationId: String,
notice: String,
notice2: String,
userHxId:String,
userName: String
): LiveConversationFragment {
val args = Bundle()
args.putString(Constants.USER_HX_ID, userHxId)
args.putString(EaseConstant.EXTRA_CONVERSATION_ID, conversationId)
args.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM)
args.putBoolean(EaseConstant.EXTRA_IS_ROAM, true)
......@@ -114,6 +116,7 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres
private fun initChatFragment() {
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.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM)
bundle.putBoolean(EaseConstant.EXTRA_IS_ROAM, true)
......
......@@ -18,6 +18,7 @@ object VersionControl {
private const val VIVO = "qj_vivo_01"
private const val HUAWEI = "qj_huawei_01"
private const val OPPO = "qj_oppo_01"
private const val XIAOMI = "qj_xiaomi_01"
fun isShowLive(): Boolean {
......@@ -26,7 +27,7 @@ object VersionControl {
fun saveConfig(showConfig: Boolean) {
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)
}
}
......
......@@ -24,6 +24,7 @@ import android.widget.RelativeLayout;
import androidx.appcompat.app.AppCompatActivity;
import com.blankj.utilcode.util.LogUtils;
import com.example.zhouwei.library.CustomPopWindow;
import com.hyphenate.easeui.modules.chat.EaseInputEditText;
import com.hyphenate.easeui.modules.chat.EaseInputMenuStyle;
......@@ -37,6 +38,8 @@ import com.hupu.tv.player.app.utils.DialogUtils;
import com.softgarden.baselibrary.utils.ToastUtil;
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 {
private LinearLayout rlBottom;
......@@ -51,7 +54,7 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar
private CheckBox buttonMore;
private Button buttonSend;
private OnSendMessageListener sendMessageListener;
private boolean isCanSend =true;
private EaseChatPrimaryMenuListener listener;
private EaseInputMenuStyle menuType = EaseInputMenuStyle.All;//菜单展示形式
protected InputMethodManager inputManager;
......@@ -76,6 +79,9 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar
public void setOnSendMessageListener(OnSendMessageListener onSendMessageListener) {
sendMessageListener = onSendMessageListener;
}
public void setCanSend(boolean canSend){
isCanSend = canSend;
}
private void initViews() {
rlBottom = findViewById(R.id.rl_bottom);
......@@ -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
public void showMoreStatus() {
if (buttonMore.isChecked()) {
......@@ -281,19 +319,7 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar
public void onClick(View v) {
int id = v.getId();
if (id == R.id.btn_send) {//发送
if (editText.getText().toString().isEmpty()){
ToastUtil.Companion.s("请输入内容");
return;
}
if (listener != null) {
String s = editText.getText().toString();
editText.setText("");
listener.onSendBtnClicked(s);
if (sendMessageListener != null) {
sendMessageListener.send(s);
}
}
sendMessage(editText.getText().toString());
} else if (id == R.id.btn_set_mode_voice) {//切换到语音模式
// showVoiceStatus();
showCustomPopWindow();
......@@ -362,12 +388,7 @@ public class CustomChatPrimaryMenu extends RelativeLayout implements IChatPrimar
@Override
public void onClickKeyboardSendBtn(String content) {
if (listener != null) {
listener.onSendBtnClicked(content);
if (sendMessageListener != null) {
sendMessageListener.send(content);
}
}
sendMessage(content);
}
@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