Android连麦申请列表重构,申请列表重构,连麦列表重构,按钮判断逻辑修改,主播断开连麦接口重构

This commit is contained in:
18401019693 2023-11-01 09:55:42 +08:00
parent a39005b1a9
commit f1a8cd3a68
8 changed files with 409 additions and 127 deletions

View File

@ -71,6 +71,38 @@ public class UserBean implements Parcelable {
//粉丝团等级 //粉丝团等级
private int fansLevel; private int fansLevel;
//粉丝团进场皮肤 //粉丝团进场皮肤
protected int typeMic;
private boolean isMicList = false;
private boolean isRequest = false;
public boolean isRequest() {
return isRequest;
}
public UserBean setRequest(boolean request) {
isRequest = request;
return this;
}
public boolean isMicList() {
return isMicList;
}
public UserBean setMicList(boolean micList) {
isMicList = micList;
return this;
}
public int getTypeMic() {
return typeMic;
}
public UserBean setTypeMic(int typeMic) {
this.typeMic = typeMic;
return this;
}
private String fansEnterRoomUrl; private String fansEnterRoomUrl;
public int getUserInfoComplete() { public int getUserInfoComplete() {

View File

@ -0,0 +1,89 @@
package com.yunbao.common.manager;
import android.content.Context;
import android.text.TextUtils;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.reflect.TypeToken;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.manager.base.BaseCacheManager;
import java.util.ArrayList;
import java.util.List;
/**
* 连麦用户申请列表维护
*/
public class MicUserManager extends BaseCacheManager {
private String micKey = "TYPE_MIC_REQUEST";
private List<UserBean> micUsers = new ArrayList<>();
private static MicUserManager manager;
public MicUserManager(Context context) {
super(context);
}
public static MicUserManager get() {
if (null == manager) {
manager = new MicUserManager(CommonAppContext.sInstance.getBaseContext());
}
return manager;
}
public void upDataMicUser(JSONObject map) {
UserBean userModel = new UserBean();
UserBean.DressBean dressAvatar = null;
if (!TextUtils.isEmpty(map.getString("dress_avatar"))) {
dressAvatar = new UserBean.DressBean();
dressAvatar.setAvatar_frame(map.getString("dress_avatar"));
}
userModel.setAvatar(map.getString("avatar"));
userModel.setId(map.getString("uid"));
userModel.setUserNiceName(map.getString("uname"));
userModel.setDress(dressAvatar);
userModel.setSex(map.getIntValue("sex"));
userModel.setLevel(map.getIntValue("level"));
userModel.setTypeMic(2);
micUsers.add(userModel);
put(micKey, micUsers);
}
public List<UserBean> getMicUserList() {
if (micUsers.size() < 1) {
micUsers = getList(micKey, new TypeToken<List<UserBean>>() {
}.getType());
}
return micUsers;
}
public void removeMiscUser(JSONObject map) {
micUsers = getMicUserList();
if (micUsers == null) return;
for (int i = 0; i < micUsers.size(); i++) {
if (TextUtils.equals(micUsers.get(i).getId(), map.getString("uid"))) {
micUsers.remove(i);
}
}
put(micKey, micUsers);
}
public void removeMiscUser(String uid) {
micUsers = getMicUserList();
if (micUsers == null) return;
for (int i = 0; i < micUsers.size(); i++) {
if (TextUtils.equals(micUsers.get(i).getId(), uid)) {
micUsers.remove(i);
}
}
put(micKey, micUsers);
}
public void removeAllMicUserList() {
deleteByKey(micKey);
micUsers.clear();
}
}

View File

@ -0,0 +1,89 @@
package com.yunbao.common.manager;
import android.content.Context;
import android.text.TextUtils;
import com.google.gson.reflect.TypeToken;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.manager.base.BaseCacheManager;
import java.util.ArrayList;
import java.util.List;
/**
* 处于连麦中的人员维护列表
*/
public class MicedUserManager extends BaseCacheManager {
private String micKey = "TYPE_MIC_LIST";
private List<UserBean> micUsers = new ArrayList<>();
public MicedUserManager(Context context) {
super(context);
}
private static MicedUserManager manager;
public static MicedUserManager get() {
if (null == manager) {
manager = new MicedUserManager(CommonAppContext.sInstance.getBaseContext());
}
return manager;
}
public void upDataMicUserList(List<LinkMicUserBean> list) {
if (list == null || list.size() < 1) return;
for (LinkMicUserBean linkMicUserBean : list) {
if (!TextUtils.equals(linkMicUserBean.getId(),
String.valueOf(IMLoginManager.get(
CommonAppContext.sInstance.getBaseContext()).
getUserInfo().getId()))) {
UserBean userModel = new UserBean();
UserBean.DressBean dressAvatar = null;
if (!TextUtils.isEmpty(linkMicUserBean.getDress_avatar())) {
dressAvatar = new UserBean.DressBean();
dressAvatar.setAvatar_frame(linkMicUserBean.getDress_avatar());
}
userModel.setAvatar(linkMicUserBean.getAvatar());
userModel.setId(linkMicUserBean.getId());
userModel.setUserNiceName(linkMicUserBean.getUname());
userModel.setSex(linkMicUserBean.getSex());
userModel.setDress(dressAvatar);
userModel.setLevel(linkMicUserBean.getLevel());
userModel.setTypeMic(1);
micUsers.add(userModel);
}
}
put(micKey, micUsers);
}
public void removeMiscUser(String uid) {
micUsers = getMicUserList();
if (micUsers == null) return;
for (int i = 0; i < micUsers.size(); i++) {
if (TextUtils.equals(micUsers.get(i).getId(), uid)) {
micUsers.remove(i);
}
}
put(micKey, micUsers);
}
public List<UserBean> getMicUserList() {
if (micUsers.size() < 1) {
micUsers = getList(micKey, new TypeToken<List<UserBean>>() {
}.getType());
}
return micUsers;
}
public void removeAllMicUserList() {
deleteByKey(micKey);
micUsers.clear();
}
}

View File

@ -1,9 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="76dp" android:height="27dp"> <item android:width="76dp" android:height="27dp" android:state_selected="true">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="#ff40beff" /> <solid android:color="#ff40beff" />
<corners android:topLeftRadius="13dp" android:topRightRadius="13dp" android:bottomLeftRadius="13dp" android:bottomRightRadius="13dp" /> <corners android:bottomLeftRadius="13dp" android:bottomRightRadius="13dp" android:topLeftRadius="13dp" android:topRightRadius="13dp" />
</shape>
</item>
<item android:width="76dp" android:height="27dp" android:state_selected="false">
<shape android:shape="rectangle">
<solid android:color="#4A4A4A" />
<corners android:bottomLeftRadius="13dp" android:bottomRightRadius="13dp" android:topLeftRadius="13dp" android:topRightRadius="13dp" />
</shape> </shape>
</item> </item>
</selector> </selector>

View File

@ -1745,7 +1745,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (liveSudGamePopupXPopup != null) { if (liveSudGamePopupXPopup != null) {
liveSudGamePopupXPopup.BusGetOff(); liveSudGamePopupXPopup.BusGetOff();
liveSudGamePopupXPopup.dialog.dismiss(); liveSudGamePopupXPopup.dialog.dismiss();
verticalViewPager.setEnableScroll(true);
liveSudGamePopupXPopup = null; liveSudGamePopupXPopup = null;
} }
break; break;

View File

@ -1,6 +1,7 @@
package com.yunbao.live.adapter; package com.yunbao.live.adapter;
import android.content.Context; import android.content.Context;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -20,20 +21,20 @@ import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.API; import com.yunbao.common.http.API;
import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.manager.MicUserManager;
import com.yunbao.common.manager.MicedUserManager;
import com.yunbao.common.utils.CommonIconUtil; import com.yunbao.common.utils.CommonIconUtil;
import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.common.bean.MicUserBean;
import com.yunbao.live.interfaces.LiveFunctionClickListener;
import com.yunbao.live.socket.SocketSendBean; import com.yunbao.live.socket.SocketSendBean;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -49,7 +50,7 @@ import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message; import io.rong.imlib.model.Message;
import io.rong.message.TextMessage; import io.rong.message.TextMessage;
public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> { public class AnchorUserMicInfoAdapter extends RefreshAdapter<UserBean> {
public static final int TYPE_MIC_LIST = 1;//连麦列表 public static final int TYPE_MIC_LIST = 1;//连麦列表
public static final int TYPE_MIC_REQUEST = 2;//请求连麦 public static final int TYPE_MIC_REQUEST = 2;//请求连麦
public static final int TYPE_MIC_INVITE = 3;//邀请连麦 public static final int TYPE_MIC_INVITE = 3;//邀请连麦
@ -116,40 +117,42 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
mBtn = itemView.findViewById(R.id.mic_btn); mBtn = itemView.findViewById(R.id.mic_btn);
mClose = itemView.findViewById(R.id.mic_exit); mClose = itemView.findViewById(R.id.mic_exit);
mBtn.setOnClickListener(v -> { mBtn.setOnClickListener(v -> {
if (MicedUserManager.get().getMicUserList().size() < 3) {
if (v.getTag() != null) { if (v.getTag() != null) {
MicUserBean tag = (MicUserBean) v.getTag(); UserBean tag = (UserBean) v.getTag();
LiveRyAnchorActivity.checkMicUserLength(mLiveUid, new LiveFunctionClickListener() { if (tag.getTypeMic() == TYPE_MIC_REQUEST) {
@Override
public void onClick(int length) {
//只允许最多3人连麦加主播4人
if (length <= 4) {
if (tag.getType() == TYPE_MIC_REQUEST) {
applyMic(tag, 4, createSocketSendBean());
ToastUtil.show(mContext.getString(R.string.live_mic_request));
} else if (tag.getType() == TYPE_MIC_INVITE) {
SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId()); SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId());
applyMic(tag, 1, bean); applyMic(tag, 1, bean);
ToastUtil.show(mContext.getString(R.string.live_mic_invite)); ToastUtil.show(mContext.getString(R.string.live_mic_invite));
} } else if (tag.getTypeMic() == TYPE_MIC_INVITE) {
} else { applyMic(tag, 4, createSocketSendBean());
ToastUtil.show(mContext.getString(R.string.live_mic_max)); ToastUtil.show(mContext.getString(R.string.live_mic_request));
for (int i = 0; i < mList.size(); i++) {
if (TextUtils.equals(mList.get(i).getId(), tag.getId())) {
mList.get(i).setRequest(true);
notifyItemChanged(i);
} }
} }
});
} }
}
}else {
ToastUtil.show(mContext.getString(R.string.live_mic_max));
}
}); });
mClose.setOnClickListener(v -> { mClose.setOnClickListener(v -> {
if (v.getTag() != null) { if (v.getTag() != null) {
API.get().createPDLiveApi(true) API.get().createPDLiveApi(false)
.killDrLm(((MicUserBean) v.getTag()).getId(), mLiveUid) .killDrLm(((UserBean) v.getTag()).getId(), mLiveUid)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(new Consumer<ResponseModel<BaseModel>>() { .subscribe(new Consumer<ResponseModel<BaseModel>>() {
@Override @Override
public void accept(ResponseModel<BaseModel> stringResponseModel) throws Exception { public void accept(ResponseModel<BaseModel> stringResponseModel) throws Exception {
applyMic((MicUserBean) v.getTag(), 8, createSocketSendBean()); applyMic((UserBean) v.getTag(), 8, createSocketSendBean());
ToastUtil.show(mContext.getString(R.string.live_mic_user_down)); ToastUtil.show(mContext.getString(R.string.live_mic_user_down));
refreshView.initData();
} }
}, Throwable::printStackTrace).isDisposed(); }, Throwable::printStackTrace).isDisposed();
@ -167,9 +170,10 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
/** /**
* 发送IM消息 * 发送IM消息
*
* @param action 4为同意请求1为邀请其余见 {@link com.yunbao.live.socket.SocketRyClient} Constants.LIAN_MAI解析 * @param action 4为同意请求1为邀请其余见 {@link com.yunbao.live.socket.SocketRyClient} Constants.LIAN_MAI解析
*/ */
void applyMic(MicUserBean bean, int action, SocketSendBean msg) { void applyMic(UserBean bean, int action, SocketSendBean msg) {
msg.param("action", action); msg.param("action", action);
msg.create(); msg.create();
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
@ -184,9 +188,17 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
@Override @Override
public void onSuccess(io.rong.imlib.model.Message message) { public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("ry", "发送成功"); Log.e("ry", "发送成功");
refreshView.initData();
IMCenter.getInstance().deleteRemoteMessages(Conversation.ConversationType.PRIVATE, message.getTargetId(), new Message[]{message}, null); IMCenter.getInstance().deleteRemoteMessages(Conversation.ConversationType.PRIVATE, message.getTargetId(), new Message[]{message}, null);
IMCenter.getInstance().clearMessagesUnreadStatus(Conversation.ConversationType.PRIVATE, message.getTargetId(), null); IMCenter.getInstance().clearMessagesUnreadStatus(Conversation.ConversationType.PRIVATE, message.getTargetId(), null);
if (bean.getTypeMic() == TYPE_MIC_REQUEST) {
MicUserManager.get().removeMiscUser(bean.getId());
}
if (bean.getTypeMic() == TYPE_MIC_LIST && action == 8) {
MicedUserManager.get().removeMiscUser(bean.getId());
}
refreshView.initData();
} }
@Override @Override
@ -197,9 +209,9 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
}); });
} }
void setData(final MicUserBean bean, int position) { void setData(final UserBean bean, int position) {
itemView.setOnClickListener(new View.OnClickListener() { mAvatar.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
((LiveActivity) mContext).showUserDialog(bean.getId()); ((LiveActivity) mContext).showUserDialog(bean.getId());
@ -208,7 +220,7 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
}); });
mClose.setTag(bean); mClose.setTag(bean);
mBtn.setTag(bean); mBtn.setTag(bean);
switch (bean.getType()) { switch (bean.getTypeMic()) {
case TYPE_MIC_LIST: case TYPE_MIC_LIST:
mClose.setVisibility(View.VISIBLE); mClose.setVisibility(View.VISIBLE);
mBtn.setVisibility(View.GONE); mBtn.setVisibility(View.GONE);
@ -219,29 +231,46 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
mBtn.setVisibility(View.VISIBLE); mBtn.setVisibility(View.VISIBLE);
break; break;
} }
if (bean.getType() == TYPE_MIC_REQUEST) { if (bean.getTypeMic() == TYPE_MIC_REQUEST) {
mBtn.setText("同意"); mBtn.setText("同意");
if(!WordUtil.isNewZh()){ if (!WordUtil.isNewZh()) {
mBtn.setText("agree"); mBtn.setText("agree");
} }
mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_ok); mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_ok);
} else if (bean.getType() == TYPE_MIC_INVITE) { } else if (bean.getTypeMic() == TYPE_MIC_INVITE) {
mBtn.setText("邀请");
if (!WordUtil.isNewZh()) {
mBtn.setText("invite");
}
mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_invite); mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_invite);
if (bean.isMicList()) {
mBtn.setEnabled(false);
mBtn.setClickable(false);
mBtn.setSelected(false);
mBtn.setText(WordUtil.isNewZh() ? "連麥中" : "Trung");
} else {
mBtn.setEnabled(true);
mBtn.setClickable(true);
mBtn.setSelected(true);
// if (bean.isRequest()){
// mBtn.setText(WordUtil.isNewZh() ? "已邀请" : "Invited");
// }else {
mBtn.setText(WordUtil.isNewZh() ? "邀请" : "invite");
// }
}
} }
ImgLoader.display(mContext, bean.getAvatar(), mAvatar); ImgLoader.display(mContext, bean.getAvatar(), mAvatar);
if (bean.getDress_avatar() != null) { gift_svga.setImageDrawable(null);
if (bean.getDress_avatar().contains("svga")) { if (bean.getDress() != null) {
if (bean.getDress().getAvatar_frame().contains("svga")) {
try { try {
new SVGAParser(mContext).parse(new URL(bean.getDress_avatar()), new SVGAParser.ParseCompletion() { new SVGAParser(mContext).parse(new URL(bean.getDress().getAvatar_frame()), new SVGAParser.ParseCompletion() {
@Override @Override
public void onComplete(SVGAVideoEntity videoItem) { public void onComplete(SVGAVideoEntity videoItem) {
SVGADrawable drawable = new SVGADrawable(videoItem); SVGADrawable drawable = new SVGADrawable(videoItem);
gift_svga.setImageDrawable(drawable); gift_svga.setImageDrawable(drawable);
SVGAViewUtils.playEndClear(gift_svga); SVGAViewUtils.playEndClear(gift_svga, false);
} }
@Override @Override
@ -252,10 +281,9 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
ImgLoader.display(mContext, bean.getDress_avatar(), gift_svga); ImgLoader.display2(mContext, bean.getDress().getAvatar_frame(), gift_svga);
} }
} }
mName.setText(bean.getUserNiceName()); mName.setText(bean.getUserNiceName());
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
@ -263,8 +291,7 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
if (levelBean != null) { if (levelBean != null) {
ImgLoader.display(mContext, levelBean.getThumb(), mLevel); ImgLoader.display(mContext, levelBean.getThumb(), mLevel);
} }
} }
} }
} }

View File

@ -4,6 +4,7 @@ import android.app.ActionBar;
import android.app.Dialog; import android.app.Dialog;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
@ -20,23 +21,23 @@ import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.LiveUserGiftBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.http.API; import com.yunbao.common.http.API;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.manager.MicUserManager;
import com.yunbao.common.manager.MicedUserManager;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.adapter.AnchorUserMicInfoAdapter; import com.yunbao.live.adapter.AnchorUserMicInfoAdapter;
import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.common.bean.LiveUserGiftBean;
import com.yunbao.common.bean.MicUserBean;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.live.utils.LiveImDeletUtil;
import com.yunbao.common.utils.MicStatusManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -58,19 +59,15 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
private AnchorUserMicInfoAdapter userMicInfoAdapter; private AnchorUserMicInfoAdapter userMicInfoAdapter;
private String mLiveUid; private String mLiveUid;
private String stream; private String stream;
private LiveGuardInfo mLiveGuardInfo;
public static LiveActivity activity = null; public static LiveActivity activity = null;
public eightbitlab.com.blurview.BlurView blurView;
public TextView listMicbtn, requestMicBtn, inviteMicBtn, mDisconnectMic; public TextView listMicbtn, requestMicBtn, inviteMicBtn, mDisconnectMic;
private TextView mNoMoreDesc; private TextView mNoMoreDesc;
private String Tips = "1"; private String Tips = "1";
private String type = "guanzhong";
View mOpenMicLayout, no_more; View mOpenMicLayout, no_more;
View mOpenMicBtn; View mOpenMicBtn;
private TreeMap<String, LinkMicUserBean> mMicQueueList = new TreeMap<>(); private TreeMap<String, LinkMicUserBean> mMicQueueList = new TreeMap<>();
private List<LiveUserGiftBean> mAudienceList = new ArrayList<>(); private List<LiveUserGiftBean> mAudienceList = new ArrayList<>();
private LiveImDeletUtil liveImDeletUtil;
private OnMicListener micListener; private OnMicListener micListener;
@Override @Override
@ -97,9 +94,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
window.setAttributes(params); window.setAttributes(params);
} }
public void setLiveGuardInfo(LiveGuardInfo info) {
mLiveGuardInfo = info;
}
public void setMicQueueList(TreeMap<String, LinkMicUserBean> mMicQueueList) { public void setMicQueueList(TreeMap<String, LinkMicUserBean> mMicQueueList) {
this.mMicQueueList = mMicQueueList; this.mMicQueueList = mMicQueueList;
@ -142,8 +136,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
if (bundle == null) { if (bundle == null) {
return; return;
} }
liveImDeletUtil = new LiveImDeletUtil();
mLiveUid = bundle.getString(Constants.LIVE_UID); mLiveUid = bundle.getString(Constants.LIVE_UID);
stream = bundle.getString(Constants.STREAM); stream = bundle.getString(Constants.STREAM);
listMicbtn = mRootView.findViewById(R.id.audience_btn); listMicbtn = mRootView.findViewById(R.id.audience_btn);
@ -168,9 +160,11 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
return; return;
} }
Tips = "1"; Tips = "1";
//
userMicInfoAdapter.clearData();
Up(); Up();
type = "guanzhong";
mRefreshView.initData(); mRefreshView.initData();
}); });
requestMicBtn.setOnClickListener(view -> { requestMicBtn.setOnClickListener(view -> {
if (!MicStatusManager.getInstance().isAnchorOpenRoom()) { if (!MicStatusManager.getInstance().isAnchorOpenRoom()) {
@ -178,7 +172,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
} }
Tips = "2"; Tips = "2";
Up(); Up();
type = "guard";
mRefreshView.initData(); mRefreshView.initData();
}); });
@ -188,9 +181,9 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
return; return;
} }
Tips = "3"; Tips = "3";
Up();
type = "fans";
mRefreshView.initData(); mRefreshView.initData();
Up();
}); });
mOpenMicBtn.setOnClickListener(v -> { mOpenMicBtn.setOnClickListener(v -> {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
@ -204,7 +197,7 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
mRefreshView.setVisibility(View.VISIBLE); mRefreshView.setVisibility(View.VISIBLE);
mDisconnectMic.setVisibility(View.VISIBLE); mDisconnectMic.setVisibility(View.VISIBLE);
MicStatusManager.getInstance().setAnchorOpenRoom(true); MicStatusManager.getInstance().setAnchorOpenRoom(true);
mRefreshView.initData(); // mRefreshView.initData();
} }
}, Throwable::printStackTrace) }, Throwable::printStackTrace)
.isDisposed(); .isDisposed();
@ -218,11 +211,14 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
mDisconnectMic.setOnClickListener(new View.OnClickListener() { mDisconnectMic.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh()?"是否確認關閉語音連麥":"Whether to disable the voice", new DialogUitl.SimpleCallback() { DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh() ? "是否確認關閉語音連麥" : "Whether to disable the voice", new DialogUitl.SimpleCallback() {
@Override @Override
public void onConfirmClick(Dialog dialog, String content) { public void onConfirmClick(Dialog dialog, String content) {
MicStatusManager.getInstance().closeMic(mContext); MicStatusManager.getInstance().closeMic(mContext);
MicUserManager.get().removeAllMicUserList();
LiveMicAnchorDialogFragment.this.dismiss(); LiveMicAnchorDialogFragment.this.dismiss();
MicedUserManager.get().removeAllMicUserList();
MicUserManager.get().removeAllMicUserList();
} }
}); });
} }
@ -231,10 +227,11 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
userMicInfoAdapter.setLiveUid(mLiveUid); userMicInfoAdapter.setLiveUid(mLiveUid);
userMicInfoAdapter.setRefreshView(mRefreshView); userMicInfoAdapter.setRefreshView(mRefreshView);
Up(); Up();
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<MicUserBean>() { mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<UserBean>() {
@Override @Override
public RefreshAdapter<MicUserBean> getAdapter() { public RefreshAdapter<UserBean> getAdapter() {
userMicInfoAdapter.notifyDataSetChanged(); userMicInfoAdapter.notifyDataSetChanged();
return userMicInfoAdapter; return userMicInfoAdapter;
} }
@ -242,54 +239,44 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
@Override @Override
public void loadData(int p, HttpCallback callback) { public void loadData(int p, HttpCallback callback) {
Log.e("tag111", p + "ssss"); Log.e("tag111", p + "ssss");
LiveHttpUtil.getMicList(mLiveUid, p, callback); LiveHttpUtil.getUserList(mLiveUid, stream, "guanzhong", p, callback);
pg = p; pg = p;
if (p == 1) {
no_more.setVisibility(View.VISIBLE);
mRefreshView.setVisibility(View.GONE);
}
} }
@Override @Override
public List<MicUserBean> processData(String[] info) { public List<UserBean> processData(String[] info) {
Log.e("tag222", Tips + "ssss" + MicStatusManager.getInstance().toString()); Log.e("tag222", Tips + "ssss" + MicStatusManager.getInstance().toString());
JSONObject obj = JSON.parseObject(info[0]); JSONObject obj = JSON.parseObject(info[0]);
List<MicUserBean> data = new ArrayList<>(); List<UserBean> data = new ArrayList<>();
if (TextUtils.equals(Tips, "2")) {
if (Tips.equals("2")) { userMicInfoAdapter.clearData();
for (String uid : mMicQueueList.keySet()) { data = MicUserManager.get().getMicUserList();
LinkMicUserBean userBean = mMicQueueList.get(uid);
MicUserBean bean = new MicUserBean(); if (data.size() == 0) {
bean.setAvatar(userBean.getAvatar()); no_more.setVisibility(View.VISIBLE);
bean.setId(uid); mRefreshView.setVisibility(View.GONE);
bean.setUserNiceName(userBean.getUname());
bean.setSex(userBean.getSex()); }else {
bean.setDress_avatar(userBean.getDress_avatar()); mRefreshView.setVisibility(View.VISIBLE);
bean.setLevel(userBean.getLevel()); no_more.setVisibility(View.GONE);
bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_REQUEST);
data.add(bean);
} }
} else if ("3".equals(Tips)) { mRefreshView.mRecyclerView.getRecycledViewPool().setMaxRecycledViews(0, data.size());
for (LiveUserGiftBean userBean : mAudienceList) { } else if (TextUtils.equals(Tips, "3")) {
MicUserBean bean = new MicUserBean(); data = JSON.parseArray(obj.getString("userlist"), UserBean.class);
bean.setAvatar(userBean.getAvatar()); for (UserBean bean : data) {
bean.setId(userBean.getId()); bean.setTypeMic(AnchorUserMicInfoAdapter.TYPE_MIC_INVITE);
bean.setUserNiceName(userBean.getUserNiceName()); for (UserBean model : MicedUserManager.get().getMicUserList()) {
bean.setSex(userBean.getSex()); if (!bean.isMicList() && TextUtils.equals(bean.getId(), model.getId())) {
bean.setDress_avatar(userBean.getDress().getAvatar_frame()); bean.setMicList(true);
bean.setLevel(userBean.getLevel());
bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_INVITE);
data.add(bean);
} }
mRefreshView.setNotLoadMore();
} else {
data = JSON.parseArray(obj.getString("userlist"), MicUserBean.class);
for (MicUserBean bean : data) {
bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_LIST);
} }
if (data.size() != 0) {
data.remove(0);
} }
if (pg == 1 && data.size() == 0) {
no_more.setVisibility(View.VISIBLE);
mRefreshView.setVisibility(View.GONE);
} }
if (data.size() > 0 && pg == 1) { if (data.size() > 0 && pg == 1) {
nums = 0; nums = 0;
@ -301,11 +288,60 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
mRefreshView.setVisibility(View.VISIBLE); mRefreshView.setVisibility(View.VISIBLE);
no_more.setVisibility(View.GONE); no_more.setVisibility(View.GONE);
} }
} else if (TextUtils.equals(Tips, "1")) {
userMicInfoAdapter.clearData();
data = MicedUserManager.get().getMicUserList();
if (data.size() == 0) {
no_more.setVisibility(View.VISIBLE);
mRefreshView.setVisibility(View.GONE);
}else {
mRefreshView.setVisibility(View.VISIBLE);
no_more.setVisibility(View.GONE);
}
mRefreshView.mRecyclerView.getRecycledViewPool().setMaxRecycledViews(0, data.size());
}
// if (Tips.equals("2")) {
// for (String uid : mMicQueueList.keySet()) {
// LinkMicUserBean userBean = mMicQueueList.get(uid);
// MicUserBean bean = new MicUserBean();
// bean.setAvatar(userBean.getAvatar());
// bean.setId(uid);
// bean.setUserNiceName(userBean.getUname());
// bean.setSex(userBean.getSex());
// bean.setDress_avatar(userBean.getDress_avatar());
// bean.setLevel(userBean.getLevel());
// bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_REQUEST);
// data.add(bean);
// }
// } else if ("3".equals(Tips)) {
// for (LiveUserGiftBean userBean : mAudienceList) {
// MicUserBean bean = new MicUserBean();
// bean.setAvatar(userBean.getAvatar());
// bean.setId(userBean.getId());
// bean.setUserNiceName(userBean.getUserNiceName());
// bean.setSex(userBean.getSex());
// bean.setDress_avatar(userBean.getDress().getAvatar_frame());
// bean.setLevel(userBean.getLevel());
// bean.setType(AnchorUserMicInfoAdapter.TYPE_MIC_INVITE);
// data.add(bean);
// }
// mRefreshView.setNotLoadMore();
// } else {
// if (data.size() != 0) {
// data.remove(0);
// }
// }
return data; return data;
} }
@Override @Override
public void onRefreshSuccess(List<MicUserBean> list, int listCount) { public void onRefreshSuccess(List<UserBean> list, int listCount) {
} }
@ -315,7 +351,7 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
} }
@Override @Override
public void onLoadMoreSuccess(List<MicUserBean> loadItemList, int loadItemCount) { public void onLoadMoreSuccess(List<UserBean> loadItemList, int loadItemCount) {
Log.e("tag333", "" + nums); Log.e("tag333", "" + nums);
} }
@ -323,7 +359,9 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
public void onLoadMoreFailure() { public void onLoadMoreFailure() {
} }
}); });
initData(); initData();
} }
@Override @Override
@ -333,7 +371,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
@Override @Override
public void onDestroy() { public void onDestroy() {
mLiveGuardInfo = null;
LiveHttpUtil.cancel("getUserLists"); LiveHttpUtil.cancel("getUserLists");
super.onDestroy(); super.onDestroy();
} }
@ -344,7 +381,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
requestMicBtn.setTextColor(Color.parseColor("#ff646464")); requestMicBtn.setTextColor(Color.parseColor("#ff646464"));
inviteMicBtn.setTextColor(Color.parseColor("#ff646464")); inviteMicBtn.setTextColor(Color.parseColor("#ff646464"));
mNoMoreDesc.setText(R.string.no_more_mic); mNoMoreDesc.setText(R.string.no_more_mic);
type = "guanzhong";
} else if (Tips.equals("2")) { } else if (Tips.equals("2")) {
listMicbtn.setTextColor(Color.parseColor("#ff646464")); listMicbtn.setTextColor(Color.parseColor("#ff646464"));
requestMicBtn.setTextColor(Color.parseColor("#fff6f7fb")); requestMicBtn.setTextColor(Color.parseColor("#fff6f7fb"));
@ -353,7 +389,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
if (!WordUtil.isNewZh()) { if (!WordUtil.isNewZh()) {
mNoMoreDesc.setText("No one has applied at the moment"); mNoMoreDesc.setText("No one has applied at the moment");
} }
type = "guard";
} else if (Tips.equals("3")) { } else if (Tips.equals("3")) {
listMicbtn.setTextColor(Color.parseColor("#ff646464")); listMicbtn.setTextColor(Color.parseColor("#ff646464"));
requestMicBtn.setTextColor(Color.parseColor("#ff646464")); requestMicBtn.setTextColor(Color.parseColor("#ff646464"));
@ -362,7 +397,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
if (!WordUtil.isNewZh()) { if (!WordUtil.isNewZh()) {
mNoMoreDesc.setText("No audience at the moment"); mNoMoreDesc.setText("No audience at the moment");
} }
type = "fans";
} }
} }

View File

@ -42,6 +42,8 @@ import com.yunbao.common.event.SendBlindGiftEvent;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.MicUserManager;
import com.yunbao.common.manager.MicedUserManager;
import com.yunbao.common.manager.NewLevelManager; import com.yunbao.common.manager.NewLevelManager;
import com.yunbao.common.manager.RandomPkManager; import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
@ -199,6 +201,7 @@ public class SocketRyClient {
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_MIC_LIST) .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_MIC_LIST)
.setObject(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class)) .setObject(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class))
); );
MicedUserManager.get().upDataMicUserList(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class));
} else if (actions == 6) { } else if (actions == 6) {
if (WordUtil.isNewZh()) { if (WordUtil.isNewZh()) {
ToastUtil.show("主播已關閉當前語音連麥功能"); ToastUtil.show("主播已關閉當前語音連麥功能");
@ -221,10 +224,12 @@ public class SocketRyClient {
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC) .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC)
.setObject(map.toJavaObject(LinkMicUserBean.class)) .setObject(map.toJavaObject(LinkMicUserBean.class))
); );
MicUserManager.get().upDataMicUser(map);
} else if (actions == 7) {//取消连麦 } else if (actions == 7) {//取消连麦
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CANCEL) .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CANCEL)
); );
MicUserManager.get().removeMiscUser(map);
} }
break; break;
case Constants.UP_USER_LIST: case Constants.UP_USER_LIST:
@ -754,7 +759,7 @@ public class SocketRyClient {
case "SudGameCreateRoom": case "SudGameCreateRoom":
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.SUD_GAME_CREATE_ROOM) .setType(LiveAudienceEvent.LiveAudienceType.SUD_GAME_CREATE_ROOM)
.setAvatar(WordUtil.isNewZh()?map.getString("sud_game_name"):map.getString("sud_game_name_en")) .setAvatar(WordUtil.isNewZh() ? map.getString("sud_game_name") : map.getString("sud_game_name_en"))
.setCreateSudRoomModel(GsonUtils.fromJson(map.toString(), SudGameDateModel.class))); .setCreateSudRoomModel(GsonUtils.fromJson(map.toString(), SudGameDateModel.class)));
break; break;