新增多人连麦主播端

This commit is contained in:
zlzw 2022-11-23 14:14:02 +08:00
parent dbba33f085
commit 202aedbcf3
20 changed files with 1151 additions and 8 deletions

View File

@ -0,0 +1,67 @@
package com.yunbao.common.bean;
public class LinkMicUserBean extends BaseModel {
private String uname;
private String avatar;
private String dress_avatar;
private String uid = "";
private String action;
private int level;
private int sex;
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getDress_avatar() {
return dress_avatar;
}
public void setDress_avatar(String dress_avatar) {
this.dress_avatar = dress_avatar;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
}

View File

@ -268,5 +268,17 @@ public interface PDLiveApi {
* PK排位赛接口 * PK排位赛接口
*/ */
@GET("/api/public/?service=Ranking.getAnchorRankData") @GET("/api/public/?service=Ranking.getAnchorRankData")
Observable<ResponseModel<PkRankBean>> getPkRanksList(@Query("anchor_id") String anchorId,@Query("anchor_id2")String pkUid); Observable<ResponseModel<PkRankBean>> getPkRanksList(@Query("anchor_id") String anchorId,@Query("anchor_id2")String pkUid); /**
* PK排位赛接口
*/
@GET("/api/public/?service=Live.createDrLm")
Observable<ResponseModel<BaseModel>> createDrLm();
/* PK排位赛接口
*/
@GET("/api/public/?service=Live.delDrLm")
Observable<ResponseModel<BaseModel>> delDrLm();
/* PK排位赛接口
*/
@GET("/api/public/?service=Live.killDrLm")
Observable<ResponseModel<BaseModel>> killDrLm(@Query("uid")String uid,@Query("roomid")String roomId);
} }

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -78,6 +78,7 @@
<string name="apply_for_lianmai">ApplyMic</string> <string name="apply_for_lianmai">ApplyMic</string>
<string name="cancel_application">Cancel Mic</string> <string name="cancel_application">Cancel Mic</string>
<string name="close_mic">Close Mic</string>
<string name="quit_mic">Quit Mic</string> <string name="quit_mic">Quit Mic</string>
<string name="edit_profile_birthday">Birthday</string> <string name="edit_profile_birthday">Birthday</string>
<string name="edit_profile_sex">Gender</string> <string name="edit_profile_sex">Gender</string>

View File

@ -70,6 +70,7 @@
<string name="edit_profile_sex">性別</string> <string name="edit_profile_sex">性別</string>
<string name="apply_for_lianmai">申请連麥</string> <string name="apply_for_lianmai">申请連麥</string>
<string name="cancel_application">取消申請</string> <string name="cancel_application">取消申請</string>
<string name="close_mic">關閉連麥</string>
<string name="quit_mic">退出連麥</string> <string name="quit_mic">退出連麥</string>
<string name="edit_profile_city">所在地</string> <string name="edit_profile_city">所在地</string>
<string name="edit_one_1">編輯個人資料</string> <string name="edit_one_1">編輯個人資料</string>
@ -617,6 +618,7 @@
<string name="glamour_list">魅力榜</string> <string name="glamour_list">魅力榜</string>
<string name="magnificent_list">豪氣榜</string> <string name="magnificent_list">豪氣榜</string>
<string name="no_more_mic">當前沒有人在語音連麥中</string> <string name="no_more_mic">當前沒有人在語音連麥中</string>
<string name="live_anchor_open_mic">語音連麥未開啟</string>
<string name="load_failure">網絡請求失敗</string> <string name="load_failure">網絡請求失敗</string>
<string name="load_failure_2">請檢查網絡連接後重試~</string> <string name="load_failure_2">請檢查網絡連接後重試~</string>
<string name="loading">加載中</string> <string name="loading">加載中</string>

View File

@ -39,6 +39,7 @@ import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.NotCancelableDialog; import com.yunbao.common.dialog.NotCancelableDialog;
@ -56,6 +57,7 @@ import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.LogUtil; import com.yunbao.common.utils.LogUtil;
import com.yunbao.common.utils.ScreenDimenUtil; import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.common.utils.StringUtil;
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.faceunity.FaceManager; import com.yunbao.faceunity.FaceManager;
@ -63,7 +65,9 @@ import com.yunbao.live.R;
import com.yunbao.live.bean.LiveGuardInfo; import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.live.bean.LiveKsyConfigBean; import com.yunbao.live.bean.LiveKsyConfigBean;
import com.yunbao.live.bean.LiveReceiveGiftBean; import com.yunbao.live.bean.LiveReceiveGiftBean;
import com.yunbao.live.bean.LiveUserGiftBean;
import com.yunbao.live.dialog.LiveLinkMicListDialogFragment; import com.yunbao.live.dialog.LiveLinkMicListDialogFragment;
import com.yunbao.live.dialog.LiveMicAnchorDialogFragment;
import com.yunbao.live.dialog.LiveNewFunctionDialogFragment; import com.yunbao.live.dialog.LiveNewFunctionDialogFragment;
import com.yunbao.live.dialog.LiveNewWishListDialogFragment; import com.yunbao.live.dialog.LiveNewWishListDialogFragment;
import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience;
@ -91,7 +95,9 @@ import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.TreeMap;
import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
@ -142,7 +148,8 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
public static int pk_nub; public static int pk_nub;
public static int backIndex = 0;//0=未判断1=已判断 public static int backIndex = 0;//0=未判断1=已判断
private FaceManager manager; private FaceManager manager;
private TreeMap<String, LinkMicUserBean> mMicQueueList = new TreeMap<>();
private List<LiveUserGiftBean> mAudienceList = new ArrayList<>();
@Override @Override
protected int getLayoutId() { protected int getLayoutId() {
@ -231,6 +238,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
*/ */
int mrr = 0; int mrr = 0;
public int leave = 0; public int leave = 0;
private LiveMicAnchorDialogFragment.OnMicListener micListener = null;
@Override @Override
public void onClick(int functionID) { public void onClick(int functionID) {
@ -239,7 +247,18 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
ToastUtil.show("開發中,敬請期待"); ToastUtil.show("開發中,敬請期待");
break; break;
case Constants.LIVE_FUNC_MIC://語音 case Constants.LIVE_FUNC_MIC://語音
ToastUtil.show("開發中,敬請期待"); //ToastUtil.show("開發中,敬請期待");
LiveMicAnchorDialogFragment fragment = new LiveMicAnchorDialogFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.LIVE_UID, mLiveUid);
bundle.putString(Constants.STREAM, mStream);
bundle.putString("By", "1");
fragment.setArguments(bundle);
micListener = fragment.getMicListener();
fragment.setMicQueueList(mMicQueueList);
fragment.setAudienceList(mAudienceList);
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
break; break;
case Constants.LIVE_FUNC_DR://多人PK case Constants.LIVE_FUNC_DR://多人PK
if (isDRPK != 1) { if (isDRPK != 1) {
@ -1301,6 +1320,39 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
leaveLive(); leaveLive();
} }
break; break;
case LINK_MIC:
if(!StringUtil.isEmpty(((LinkMicUserBean) event.getObject()).getUid())) {
mMicQueueList.put(((LinkMicUserBean) event.getObject()).getUid(), (LinkMicUserBean) event.getObject());
}
if (micListener != null) {
micListener.updateMicList(mMicQueueList);
}
break;
case LINK_MIC_CANCEL:
mMicQueueList.remove(((LinkMicUserBean) event.getObject()).getUid());
if (micListener != null) {
micListener.updateMicList(mMicQueueList);
}
break;
case LINK_MIC_UPDATE_MIC_LIST:
List<LinkMicUserBean> list = (List<LinkMicUserBean>) event.getObject();
mMicQueueList.clear();
for (LinkMicUserBean bean : list) {
if(!StringUtil.isEmpty(bean.getUid())) {
mMicQueueList.put(bean.getUid(), bean);
} }
} }
if (micListener != null) {
micListener.updateMicList(mMicQueueList);
}
break;
case LINK_MIC_UPDATE_AUDIENCE_LIST:
mAudienceList = (List<LiveUserGiftBean>) event.getObject();
if (micListener != null) {
micListener.updateAudienceList(mAudienceList);
}
break;
}
}
} }

View File

@ -0,0 +1,234 @@
package com.yunbao.live.adapter;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.API;
import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.utils.CommonIconUtil;
import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.bean.MicUserBean;
import com.yunbao.live.event.LiveRoomChangeEvent;
import com.yunbao.live.socket.SocketSendBean;
import org.greenrobot.eventbus.EventBus;
import java.net.MalformedURLException;
import java.net.URL;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.message.TextMessage;
public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
public static final int TYPE_MIC_LIST = 1;//连麦列表
public static final int TYPE_MIC_REQUEST = 2;//请求连麦
public static final int TYPE_MIC_INVITE = 3;//邀请连麦
private AbsDialogFragment fragments;
private String mLiveUid;
public AnchorUserMicInfoAdapter(Context context, AbsDialogFragment fragment) {
super(context);
this.fragments = fragment;
}
@Override
public int getItemViewType(int position) {
return position;
}
public void setLiveUid(String mLiveUid) {
this.mLiveUid = mLiveUid;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new AnchorUserMicInfoAdapter.Vh(mInflater.inflate(R.layout.item_anchor_mic_info, parent, false));
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
// vh.setIsRecyclable(false);
((AnchorUserMicInfoAdapter.Vh) vh).setData(mList.get(position), position);
}
@Override
public int getItemCount() {
return mList.size();
}
class Vh extends RecyclerView.ViewHolder {
ImageView mAvatar;
TextView mName;
ImageView mSex;
ImageView mLevel;
ImageView mClose;
SVGAImageView gift_svga;
Button mBtn;
public Vh(@NonNull View itemView) {
super(itemView);
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
mName = (TextView) itemView.findViewById(R.id.name);
mSex = (ImageView) itemView.findViewById(R.id.sex);
mLevel = (ImageView) itemView.findViewById(R.id.level);
gift_svga = (SVGAImageView) itemView.findViewById(R.id.gift_svga);
mBtn = itemView.findViewById(R.id.mic_btn);
mClose = itemView.findViewById(R.id.mic_exit);
mBtn.setOnClickListener(v -> {
if (v.getTag() != null) {
MicUserBean tag = (MicUserBean) v.getTag();
if(tag.getType()==TYPE_MIC_REQUEST) {
applyMic(tag, 4,createSocketSendBean());
}else if(tag.getType()==TYPE_MIC_INVITE){
SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId());
applyMic(tag, 1,bean);
}
}
});
mClose.setOnClickListener(v -> {
if (v.getTag() != null) {
API.get().createPDLiveApi(true)
.killDrLm(((MicUserBean) v.getTag()).getId(), mLiveUid)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
@Override
public void accept(ResponseModel<BaseModel> stringResponseModel) throws Exception {
applyMic((MicUserBean) v.getTag(), 8,createSocketSendBean());
}
}, Throwable::printStackTrace).isDisposed();
}
});
}
SocketSendBean createSocketSendBean(){
return new SocketSendBean()
.param("_method_", Constants.LIAN_MAI)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("uid", CommonAppConfig.getInstance().getUid());
}
void applyMic(MicUserBean bean, int action,SocketSendBean msg) {
msg.param("action", action);
msg.create();
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(bean.getId(), conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(io.rong.imlib.model.Message message) {
}
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("ry", "发送成功");
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("ry", "发送失敗" + errorCode.toString());
}
});
}
void setData(final MicUserBean bean, int position) {
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((LiveActivity) mContext).showUserDialog(bean.getId());
fragments.dismiss();
}
});
mClose.setTag(bean);
mBtn.setTag(bean);
switch (bean.getType()) {
case TYPE_MIC_LIST:
mClose.setVisibility(View.VISIBLE);
mBtn.setVisibility(View.GONE);
break;
case TYPE_MIC_REQUEST:
case TYPE_MIC_INVITE:
mClose.setVisibility(View.GONE);
mBtn.setVisibility(View.VISIBLE);
break;
}
if (bean.getType() == TYPE_MIC_REQUEST) {
mBtn.setText("同意");
mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_ok);
} else if (bean.getType() == TYPE_MIC_INVITE) {
mBtn.setText("邀请");
mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_invite);
}
ImgLoader.display(mContext, bean.getAvatar(), mAvatar);
if (bean.getDress_avatar() != null) {
if (bean.getDress_avatar().contains("svga")) {
try {
new SVGAParser(mContext).parse(new URL(bean.getDress_avatar()), new SVGAParser.ParseCompletion() {
@Override
public void onComplete(SVGAVideoEntity videoItem) {
SVGADrawable drawable = new SVGADrawable(videoItem);
gift_svga.setImageDrawable(drawable);
SVGAViewUtils.playEndClear(gift_svga);
}
@Override
public void onError() {
}
});
} catch (MalformedURLException e) {
e.printStackTrace();
}
} else {
ImgLoader.display(mContext, bean.getDress_avatar(), gift_svga);
}
}
mName.setText(bean.getUserNiceName());
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
if (levelBean != null) {
ImgLoader.display(mContext, levelBean.getThumb(), mLevel);
}
}
}
}

View File

@ -9,6 +9,7 @@ public class MicUserBean {
protected int level; protected int level;
protected int sex; protected int sex;
protected String dress_avatar; protected String dress_avatar;
protected int type;
@JSONField(name = "dress_avatar") @JSONField(name = "dress_avatar")
public String getDress_avatar() { public String getDress_avatar() {
@ -65,4 +66,12 @@ public class MicUserBean {
public void setAvatar(String avatar) { public void setAvatar(String avatar) {
this.avatar = avatar; this.avatar = avatar;
} }
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
} }

View File

@ -0,0 +1,407 @@
package com.yunbao.live.dialog;
import static com.yunbao.live.views.LivePlayRyViewHolder.Micing;
import android.app.ActionBar;
import android.app.Dialog;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.http.API;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.adapter.AnchorUserMicInfoAdapter;
import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.live.bean.LiveUserGiftBean;
import com.yunbao.live.bean.MicUserBean;
import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.utils.LiveImDeletUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.TreeMap;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
/**
* 连麦列表
* 主播端
*/
public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements View.OnClickListener {
private CommonRefreshView mRefreshView;
private View view_no;
private AnchorUserMicInfoAdapter userMicInfoAdapter;
private String mLiveUid;
private String stream;
private LiveGuardInfo mLiveGuardInfo;
public static LiveActivity activity = null;
public eightbitlab.com.blurview.BlurView blurView;
public TextView listMicbtn, requestMicBtn, inviteMicBtn, mDisconnectMic;
private TextView mNoMoreDesc;
private String Tips = "1";
private String type = "guanzhong";
View mOpenMicLayout, no_more;
View mOpenMicBtn;
private TreeMap<String, LinkMicUserBean> mMicQueueList = new TreeMap<>();
private List<LiveUserGiftBean> mAudienceList = new ArrayList<>();
private LiveImDeletUtil liveImDeletUtil;
private OnMicListener micListener;
@Override
protected int getLayoutId() {
return R.layout.dialog_anchor_mic_list;
}
@Override
protected int getDialogStyle() {
return R.style.dialog2;
}
@Override
protected boolean canCancel() {
return true;
}
@Override
protected void setWindowAttributes(Window window) {
WindowManager.LayoutParams params = window.getAttributes();
params.width = ActionBar.LayoutParams.MATCH_PARENT;
params.height = DpUtil.dp2px(460);
params.gravity = Gravity.BOTTOM;
window.setAttributes(params);
}
public void setLiveGuardInfo(LiveGuardInfo info) {
mLiveGuardInfo = info;
}
public void setMicQueueList(TreeMap<String, LinkMicUserBean> mMicQueueList) {
this.mMicQueueList = mMicQueueList;
}
public void setAudienceList(List<LiveUserGiftBean> mAudienceList) {
this.mAudienceList = mAudienceList;
}
public OnMicListener getMicListener() {
if (micListener == null) {
micListener = new OnMicListener() {
@Override
public void updateMicList(TreeMap<String, LinkMicUserBean> list) {
mMicQueueList = list;
if ("2".equals(Tips)) {
mRefreshView.initData();
}
}
@Override
public void updateAudienceList(List<LiveUserGiftBean> list) {
mAudienceList = list;
if ("3".equals(Tips)) {
mRefreshView.initData();
}
}
};
}
return micListener;
}
int nums = 0;
int pg = 1;
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Bundle bundle = getArguments();
if (bundle == null) {
return;
}
liveImDeletUtil = new LiveImDeletUtil();
mLiveUid = bundle.getString(Constants.LIVE_UID);
stream = bundle.getString(Constants.STREAM);
listMicbtn = mRootView.findViewById(R.id.audience_btn);
mOpenMicLayout = mRootView.findViewById(R.id.anchor_open_mic);
no_more = mRootView.findViewById(R.id.no_more);
mOpenMicBtn = mRootView.findViewById(R.id.open_mic);
mNoMoreDesc = mRootView.findViewById(R.id.no_more_desc);
Tips = bundle.getString("By");
listMicbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!isOpenRoom()) {
return;
}
Tips = "1";
Up();
type = "guanzhong";
mRefreshView.initData();
}
});
requestMicBtn = mRootView.findViewById(R.id.guard_btn);
requestMicBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!isOpenRoom()) {
return;
}
Tips = "2";
Up();
type = "guard";
mRefreshView.initData();
}
});
inviteMicBtn = mRootView.findViewById(R.id.fans_btn);
inviteMicBtn.setVisibility(View.VISIBLE);
inviteMicBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!isOpenRoom()) {
return;
}
Tips = "3";
Up();
type = "fans";
mRefreshView.initData();
}
});
mOpenMicBtn.setOnClickListener(v -> {
API.get().pdLiveApi(mContext)
.createDrLm()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
@Override
public void accept(ResponseModel<BaseModel> stringResponseModel) throws Exception {
mOpenMicLayout.setVisibility(View.GONE);
mRefreshView.setVisibility(View.VISIBLE);
mDisconnectMic.setVisibility(View.VISIBLE);
isOpenRoom = true;
mRefreshView.initData();
}
}, Throwable::printStackTrace)
.isDisposed();
});
mRefreshView = mRootView.findViewById(R.id.refreshView);
view_no = mRootView.findViewById(R.id.view_no);
mDisconnectMic = mRootView.findViewById(R.id.apply_btn);
mDisconnectMic.setBackgroundResource(R.drawable.background_eb6877);
mDisconnectMic.setText(R.string.close_mic);
mDisconnectMic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
closeMic();
}
});
userMicInfoAdapter = new AnchorUserMicInfoAdapter(mContext, LiveMicAnchorDialogFragment.this);
userMicInfoAdapter.setLiveUid(mLiveUid);
Up();
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<MicUserBean>() {
@Override
public RefreshAdapter<MicUserBean> getAdapter() {
userMicInfoAdapter.notifyDataSetChanged();
return userMicInfoAdapter;
}
@Override
public void loadData(int p, HttpCallback callback) {
Log.e("tag111", p + "ssss");
LiveHttpUtil.getMicList(mLiveUid, p, callback);
pg = p;
if (p == 1) {
no_more.setVisibility(View.VISIBLE);
mRefreshView.setVisibility(View.GONE);
}
}
@Override
public List<MicUserBean> processData(String[] info) {
Log.e("tag222", Tips + "ssss" + Micing);
JSONObject obj = JSON.parseObject(info[0]);
List<MicUserBean> data = new ArrayList<>();
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);
}
} 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 (data.size() > 0 && pg == 1) {
nums = 0;
view_no.setVisibility(View.GONE);
if (nums == 0) {
view_no.setVisibility(View.VISIBLE);
}
mRefreshView.mRecyclerView.getRecycledViewPool().setMaxRecycledViews(0, data.size());
mRefreshView.setVisibility(View.VISIBLE);
no_more.setVisibility(View.GONE);
}
return data;
}
@Override
public void onRefreshSuccess(List<MicUserBean> list, int listCount) {
}
@Override
public void onRefreshFailure() {
}
@Override
public void onLoadMoreSuccess(List<MicUserBean> loadItemList, int loadItemCount) {
Log.e("tag333", "" + nums);
}
@Override
public void onLoadMoreFailure() {
}
});
mRefreshView.initData();
initData();
}
@Override
public void onClick(View v) {
dismiss();
}
@Override
public void onDestroy() {
mLiveGuardInfo = null;
LiveHttpUtil.cancel("getUserLists");
super.onDestroy();
}
void Up() {
if (Tips.equals("1")) {
listMicbtn.setTextColor(Color.parseColor("#fff6f7fb"));
requestMicBtn.setTextColor(Color.parseColor("#ff646464"));
inviteMicBtn.setTextColor(Color.parseColor("#ff646464"));
mNoMoreDesc.setText(R.string.no_more_mic);
type = "guanzhong";
} else if (Tips.equals("2")) {
listMicbtn.setTextColor(Color.parseColor("#ff646464"));
requestMicBtn.setTextColor(Color.parseColor("#fff6f7fb"));
inviteMicBtn.setTextColor(Color.parseColor("#ff646464"));
mNoMoreDesc.setText("當前沒有人申請");
type = "guard";
} else if (Tips.equals("3")) {
listMicbtn.setTextColor(Color.parseColor("#ff646464"));
requestMicBtn.setTextColor(Color.parseColor("#ff646464"));
inviteMicBtn.setTextColor(Color.parseColor("#fff6f7fb"));
mNoMoreDesc.setText("當前沒有觀眾");
type = "fans";
}
}
private boolean isOpenRoom = false;
private void initData() {
LiveHttpUtil.getMicList(mLiveUid, 0, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
System.out.println("code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
if (code != 0) {
mOpenMicLayout.setVisibility(View.VISIBLE);
mRefreshView.setVisibility(View.GONE);
no_more.setVisibility(View.GONE);
mDisconnectMic.setVisibility(View.INVISIBLE);
} else {
isOpenRoom = true;
}
}
});
}
private boolean isOpenRoom() {
return isOpenRoom;
}
private void closeMic() {
DialogUitl.showSimpleDialog(mContext, "是否確認關閉語音連麥", new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
API.get().pdLiveApi(mContext)
.delDrLm()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
@Override
public void accept(ResponseModel<BaseModel> stringResponseModel) throws Exception {
System.out.println("stringResponseModel.getData() = " + stringResponseModel.getData());
LiveMicAnchorDialogFragment.this.dismiss();
}
}, Throwable::printStackTrace)
.isDisposed();
}
});
}
public interface OnMicListener {
void updateMicList(TreeMap<String, LinkMicUserBean> list);
void updateAudienceList(List<LiveUserGiftBean> list);
}
}

View File

@ -183,7 +183,10 @@ public class LiveMicUserDialogFragment extends AbsDialogFragment implements View
.param("_method_", Constants.LIAN_MAI) .param("_method_", Constants.LIAN_MAI)
.param("action", 3) .param("action", 3)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("sex", CommonAppConfig.getInstance().getUserBean().getSex())
.param("level", CommonAppConfig.getInstance().getUserBean().getLevel())
.param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("dress_avatar", CommonAppConfig.getInstance().getUserBean().getDress().getAvatar_frame())
.param("uid", CommonAppConfig.getInstance().getUid()); .param("uid", CommonAppConfig.getInstance().getUid());
msg1.create(); msg1.create();

View File

@ -189,6 +189,10 @@ public class LiveAudienceEvent extends BaseModel {
PK_TWO_START(36, "双人PK开始"), PK_TWO_START(36, "双人PK开始"),
PK_TWO_UPDATE_HEAD_DATA(37, "更新PK头像信息"), PK_TWO_UPDATE_HEAD_DATA(37, "更新PK头像信息"),
PK_TWO_END(38, "双人PK开始"), PK_TWO_END(38, "双人PK开始"),
LINK_MIC(39, "连麦"),
LINK_MIC_CANCEL(40, "取消连麦"),
LINK_MIC_UPDATE_MIC_LIST(41, "更新连麦列表"),
LINK_MIC_UPDATE_AUDIENCE_LIST(42, "更新观众/可邀请列表"),
; ;
private int type; private int type;

View File

@ -16,6 +16,7 @@ import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils; import com.blankj.utilcode.util.GsonUtils;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
@ -23,6 +24,7 @@ import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.AiAutomaticSpeechModel;
import com.yunbao.common.bean.FansMedalBean; import com.yunbao.common.bean.FansMedalBean;
import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.PkRankBean; import com.yunbao.common.bean.PkRankBean;
import com.yunbao.common.bean.SocketModel; import com.yunbao.common.bean.SocketModel;
@ -170,6 +172,10 @@ public class SocketRyClient {
} else if (actions == 5) { } else if (actions == 5) {
JSONObject mic_data = map.getJSONObject("ct"); JSONObject mic_data = map.getJSONObject("ct");
LiveRoomViewHolder.updataMicList(mic_data.getJSONArray("userlist")); LiveRoomViewHolder.updataMicList(mic_data.getJSONArray("userlist"));
EventBus.getDefault().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_MIC_LIST)
.setObject(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(),LinkMicUserBean.class))
);
} else if (actions == 6) { } else if (actions == 6) {
ToastUtil.show("主播已關閉當前語音連麥功能"); ToastUtil.show("主播已關閉當前語音連麥功能");
LiveRoomViewHolder.updataCleanMic(); LiveRoomViewHolder.updataCleanMic();
@ -177,10 +183,24 @@ public class SocketRyClient {
} else if (actions == 8) { } else if (actions == 8) {
ToastUtil.show("您已被移出多人語音連麥"); ToastUtil.show("您已被移出多人語音連麥");
EventBus.getDefault().post("endMic"); EventBus.getDefault().post("endMic");
}else if(actions==3){
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC)
.setObject(map.toJavaObject(LinkMicUserBean.class))
);
}else if (actions==7){//取消连麦
EventBus.getDefault().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CANCEL)
.setObject(map.toJavaObject(LinkMicUserBean.class))
);
} }
break; break;
case Constants.UP_USER_LIST: case Constants.UP_USER_LIST:
mListener.onUpUserList(map.getJSONObject("ct")); mListener.onUpUserList(map.getJSONObject("ct"));
EventBus.getDefault().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_AUDIENCE_LIST)
.setObject(JSON.parseArray(map.getJSONObject("ct").getString("userlist"), LiveUserGiftBean.class))
);
break; break;
case Constants.CARD: case Constants.CARD:
// LiveLinkMicPresenter.setHD(map.getString("ct")); // LiveLinkMicPresenter.setHD(map.getString("ct"));

View File

@ -200,14 +200,24 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
public static void upData(String votes, String length, int nums, String uname) { public static void upData(String votes, String length, int nums, String uname) {
Log.e("", votes + "votes" + length + "length" + nums + "nums"); Log.e("", votes + "votes" + length + "length" + nums + "nums");
if (type == LiveOfType.USER) { if (type == LiveOfType.USER) {
if (liveDurationUser != null) {
liveDurationUser.setText(length); liveDurationUser.setText(length);
}
if (liveNameUser != null) {
liveNameUser.setText(uname); liveNameUser.setText(uname);
}
} else { } else {
if (liveDurationAnchor != null) {
liveDurationAnchor.setText(length); liveDurationAnchor.setText(length);
}
if (liveVotes != null) {
liveVotes.setText(votes); liveVotes.setText(votes);
}
if (liveWatchNum != null) {
liveWatchNum.setText(StringUtil.toWan(nums)); liveWatchNum.setText(StringUtil.toWan(nums));
} }
} }
}
public void showData(LiveBean liveBean, final String stream) { public void showData(LiveBean liveBean, final String stream) {
if (TextUtils.equals(model.getId() + "", liveBean.getUid())) { if (TextUtils.equals(model.getId() + "", liveBean.getUid())) {

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="233dp" android:height="40dp">
<shape android:shape="rectangle">
<solid android:color="#ff0fdab8" />
<corners android:topLeftRadius="20dp" android:topRightRadius="20dp" android:bottomLeftRadius="20dp" android:bottomRightRadius="20dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/anchor_open_mic"
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="63dp"
android:layout_height="93dp"
android:src="@mipmap/icon_big_mic" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="27dp"
android:text="@string/live_anchor_open_mic"
android:textColor="#ffb1b1b1"
android:textSize="14sp" />
<LinearLayout
android:id="@+id/open_mic"
android:layout_width="233dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:background="@drawable/bg_live_anchor_open_mic"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:text="打開語音連麥權限"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:layout_marginBottom="8dp"
android:text="粉絲等級5以上的用戶可向您發起申請"
android:textColor="#259484"
android:textSize="8sp" />
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg_black"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="24dp"
android:orientation="horizontal">
<TextView
android:id="@+id/audience_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="當前連麥"
android:textColor="#fff6f7fb"
android:textSize="16sp" />
<TextView
android:id="@+id/guard_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="連麥申請"
android:textColor="#ff646464"
android:textSize="16sp" />
<TextView
android:id="@+id/fans_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="邀請連麥"
android:visibility="gone"
android:textColor="#EB6877"
android:textSize="16sp" />
<TextView
android:id="@+id/apply_btn"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:layout_weight="1"
android:layout_marginRight="15dp"
android:layout_marginLeft="5dp"
android:gravity="center"
android:text="@string/apply_for_lianmai"
android:textColor="#FFFFFF"
android:background="@drawable/background_0fdab8"
android:textSize="12sp" />
</LinearLayout>
<View
android:id="@+id/view_no"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="gone" />
<include
layout="@layout/anchor_open_mic_view"
android:layout_width="233dp"
android:layout_height="233dp"
android:layout_gravity="center"
android:visibility="gone" />
<include
layout="@layout/no_more_mic_view"
android:layout_width="233dp"
android:layout_height="233dp"
android:layout_gravity="center"
android:visibility="gone" />
<com.yunbao.common.custom.CommonRefreshView
android:id="@+id/refreshView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="65dp" />
</LinearLayout>
</RelativeLayout>

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="69dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_marginLeft="27dp"
android:gravity="center">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/avatar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:scaleType="centerCrop"
android:src="@drawable/m_chu_xia"
app:riv_oval="true" />
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/gift_svga"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:scaleType="centerCrop"
app:autoPlay="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名称"
android:textColor="#F6F7FB"
android:textSize="14sp" />
<ImageView
android:id="@+id/noble"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="5dp"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/sex"
android:layout_width="18dp"
android:layout_height="15dp" />
<ImageView
android:id="@+id/level"
android:layout_width="30dp"
android:layout_height="15dp"
android:layout_marginLeft="5dp" />
</LinearLayout>
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/mic_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="27dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/mic_exit"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/beauty_jingbai" />
<ImageView
android:id="@+id/mic_exit"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="36dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/btn_icon_quit" />
<Button
android:id="@+id/mic_btn"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:layout_marginEnd="36dp"
android:background="@drawable/bg_anchor_mic_info_btn_ok"
android:text="同意"
android:textColor="#FFFFFF"
android:textSize="12sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -12,6 +12,7 @@
android:src="@mipmap/icon_big_mic"/> android:src="@mipmap/icon_big_mic"/>
<TextView <TextView
android:id="@+id/no_more_desc"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/no_more_mic" android:text="@string/no_more_mic"