diff --git a/common/src/main/java/com/yunbao/common/bean/LinkMicUserBean.java b/common/src/main/java/com/yunbao/common/bean/LinkMicUserBean.java index b677d931e..820dc6062 100644 --- a/common/src/main/java/com/yunbao/common/bean/LinkMicUserBean.java +++ b/common/src/main/java/com/yunbao/common/bean/LinkMicUserBean.java @@ -1,12 +1,21 @@ package com.yunbao.common.bean; +import com.google.gson.annotations.SerializedName; + public class LinkMicUserBean extends BaseModel { + @SerializedName("user_nicename") private String uname; + @SerializedName("avatar") private String avatar; + @SerializedName("dress_avatar") private String dress_avatar; private String uid = ""; private String action; + @SerializedName("id") + private String id;//连麦显示右侧头像时要用 + @SerializedName("level") private int level; + @SerializedName("sex") private int sex; public String getUname() { @@ -64,4 +73,26 @@ public class LinkMicUserBean extends BaseModel { public void setSex(int sex) { this.sex = sex; } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public String toString() { + return "LinkMicUserBean{" + + "uname='" + uname + '\'' + + ", avatar='" + avatar + '\'' + + ", dress_avatar='" + dress_avatar + '\'' + + ", uid='" + uid + '\'' + + ", action='" + action + '\'' + + ", id='" + id + '\'' + + ", level=" + level + + ", sex=" + sex + + '}'; + } } diff --git a/common/src/main/java/com/yunbao/common/bean/LinkMicUserBeanV2.java b/common/src/main/java/com/yunbao/common/bean/LinkMicUserBeanV2.java new file mode 100644 index 000000000..23bac2d3f --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/LinkMicUserBeanV2.java @@ -0,0 +1,33 @@ +package com.yunbao.common.bean; + +import java.util.List; + +public class LinkMicUserBeanV2 extends BaseModel { + private String roomuserid; + private int status; + private List userlist; + + public String getRoomuserid() { + return roomuserid; + } + + public void setRoomuserid(String roomuserid) { + this.roomuserid = roomuserid; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public List getUserlist() { + return userlist; + } + + public void setUserlist(List userlist) { + this.userlist = userlist; + } +} diff --git a/live/src/main/java/com/yunbao/live/bean/MicUserBean.java b/common/src/main/java/com/yunbao/common/bean/MicUserBean.java similarity index 95% rename from live/src/main/java/com/yunbao/live/bean/MicUserBean.java rename to common/src/main/java/com/yunbao/common/bean/MicUserBean.java index c2d7b9d0c..48591cb96 100644 --- a/live/src/main/java/com/yunbao/live/bean/MicUserBean.java +++ b/common/src/main/java/com/yunbao/common/bean/MicUserBean.java @@ -1,8 +1,8 @@ -package com.yunbao.live.bean; +package com.yunbao.common.bean; import com.alibaba.fastjson.annotation.JSONField; -public class MicUserBean { +public class MicUserBean extends BaseModel{ protected String id; protected String userNiceName; protected String avatar; diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index bb152c0d4..255462408 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -10,6 +10,7 @@ import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.HourRank; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.LinkMicUserBeanV2; import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.LiveRoomActivityBanner; import com.yunbao.common.bean.MsgSwitchDetailModel; @@ -173,10 +174,10 @@ public interface PDLiveApi { Observable>> getActiveList(); /** - * 获取活动 + * 获取多人连麦列表 */ @GET("/api/public/?service=live.getDrLm") - Observable>> getDrLm(); + Observable>> getDrLm(@Query("uid")String uid); /** * 获取日榜、周榜数据 diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 29a01f9ca..ff618e38d 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -11,6 +11,8 @@ import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.EnterRoomNewModel; +import com.yunbao.common.bean.LinkMicUserBean; +import com.yunbao.common.bean.LinkMicUserBeanV2; import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.LiveRoomActivityBanner; import com.yunbao.common.bean.NobleRankHideUserListModel; @@ -23,6 +25,7 @@ import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.base.CheckLiveCallBack; import com.yunbao.common.http.base.HttpCallback; +import java.util.ArrayList; import java.util.List; import io.reactivex.android.schedulers.AndroidSchedulers; @@ -373,7 +376,7 @@ public class LiveNetManager { .subscribe(new Consumer>() { @Override public void accept(ResponseModel enterRoomNewModelResponseModel) throws Exception { - Log.e("进入房间","enterRoomNew--------------------------------------------"); + Log.e("进入房间", "enterRoomNew--------------------------------------------"); enterRoomDisposable = null; if (callback != null) { callback.onSuccess(enterRoomNewModelResponseModel.getData().getInfo()); @@ -406,7 +409,7 @@ public class LiveNetManager { .subscribe(new Consumer>() { @Override public void accept(ResponseModel stringResponseModel) throws Exception { - Log.e("进入房间","userJoinRoomNew--------------------------------------------"); + Log.e("进入房间", "userJoinRoomNew--------------------------------------------"); userJoinDisposable = null; } }, new Consumer() { @@ -445,6 +448,39 @@ public class LiveNetManager { }).isDisposed(); } + /** + * 获取多人连麦用户列表 + */ + public void getDRMicUserList(String uid, HttpCallback> callback) { + API.get().createPDLiveApi(false) + .getDrLm(uid) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + List list=new ArrayList<>(); + for (LinkMicUserBeanV2 bean : listResponseModel.getData().getInfo()) { + list.addAll(bean.getUserlist()); + for (LinkMicUserBean userBean : bean.getUserlist()) { + Log.i("多人连麦", "list: " + userBean.toString()); + } + } + Log.i("多人连麦", "accept: " + list.size()); + if (callback != null) { + callback.onSuccess(list); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ diff --git a/common/src/main/java/com/yunbao/common/utils/MicStatusManager.java b/common/src/main/java/com/yunbao/common/utils/MicStatusManager.java index be60682b1..034b27f22 100644 --- a/common/src/main/java/com/yunbao/common/utils/MicStatusManager.java +++ b/common/src/main/java/com/yunbao/common/utils/MicStatusManager.java @@ -169,10 +169,10 @@ public class MicStatusManager { * 显示退出连麦状态对话框 */ public void showDownMicDialog(Context context) { - DialogUitl.showSimpleDialog(context, "當前正在連麥中,是否退出連麥", new DialogUitl.SimpleCallback() { + DialogUitl.showSimpleDialog(context, "當前正在連麥中", new DialogUitl.SimpleCallback() { @Override public void onConfirmClick(Dialog dialog, String content) { - downMic(); + // downMic(); //不做下麦跳转 } }); } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index 82c1eb317..fae9f031f 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -23,6 +23,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.WebViewActivity; import com.yunbao.common.bean.ConfigBean; +import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveGiftBean; import com.yunbao.common.bean.LiveUserGiftBean; @@ -60,6 +61,7 @@ import com.yunbao.live.dialog.LiveGiveHotDialogFragment; import com.yunbao.live.dialog.LiveGuardBuyDialogFragment; import com.yunbao.live.dialog.LiveGuardDialogFragment; import com.yunbao.live.dialog.LiveInputDialogFragment; +import com.yunbao.live.dialog.LiveMicAnchorDialogFragment; import com.yunbao.live.dialog.LiveMoreDialogFragment; import com.yunbao.live.dialog.LiveNewGuardBuyDialogFragment; import com.yunbao.live.dialog.LiveNewGuardListDialogFragment; @@ -96,6 +98,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.TreeMap; /** * Created by cxf on 2018/10/7. @@ -146,7 +149,9 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL // public static boolean isRy = true; private List outRankHide = new ArrayList<>(); private boolean outRankHideFirst = true; - + protected TreeMap mMicQueueList = new TreeMap<>(); + protected List mAudienceList = new ArrayList<>(); + protected LiveMicAnchorDialogFragment.OnMicListener micListener = null; @Override protected void main() { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -1554,6 +1559,41 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } } + /** + * 打开连麦UI + */ + protected void openMicWindow(int index) { + LiveMicAnchorDialogFragment fragment = new LiveMicAnchorDialogFragment(); + Bundle bundle = new Bundle(); + bundle.putString(Constants.LIVE_UID, mLiveUid); + bundle.putString(Constants.STREAM, mStream); + bundle.putString("By", index + ""); + fragment.setArguments(bundle); + micListener = fragment.getMicListener(); + fragment.setMicQueueList(mMicQueueList); + fragment.setAudienceList(mAudienceList); + fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment"); + } + + /** + * 获取连麦列表 + */ + public void showMicList(String uid,LiveRoomViewHolder mLiveRoomViewHolder) { + LiveNetManager.get(mContext) + .getDRMicUserList(uid, new com.yunbao.common.http.base.HttpCallback>() { + @Override + public void onSuccess(List data) { + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.updataMicList(data); + } + } + + @Override + public void onError(String error) { + System.out.println("live.getDrLm error = " + error); + } + }); + } @Override protected void onDestroy() { release(); diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index a03b431e5..abd2b7a8f 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -1,6 +1,7 @@ package com.yunbao.live.activity; import android.annotation.SuppressLint; +import android.app.Dialog; import android.content.Intent; import android.content.res.Configuration; import android.media.AudioManager; @@ -41,8 +42,10 @@ import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.CrashSaveBean; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveGiftBean; +import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.SlideInfoModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.EffectsSettingsDialog; @@ -68,7 +71,9 @@ import com.yunbao.common.utils.L; import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.ProcessResultUtil; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.CustomDrawerPopupView; import com.yunbao.common.views.floatingview.APPEasyFloat; import com.yunbao.common.views.weight.VerticalViewPager; @@ -1132,7 +1137,60 @@ public class LiveAudienceActivity extends LiveActivity { case LUCKY_ANGEL: manager.luckyAngel(event.getMsgModel()); 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); + DialogUitl.showSimpleDialog(mContext, + String.format(WordUtil.getString(R.string.live_mic_user_apply), ((LinkMicUserBean) event.getObject()).getUname()), + new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + openMicWindow(2); + dialog.dismiss(); + } + } + ); + } + 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 list = (List) event.getObject(); + mMicQueueList.clear(); + for (LinkMicUserBean bean : list) { + if (!StringUtil.isEmpty(bean.getUid())) { + mMicQueueList.put(bean.getUid(), bean); + } + } + if (micListener != null) { + micListener.updateMicList(mMicQueueList); + } + if (manager.mLiveRoomViewHolder != null) { + manager.mLiveRoomViewHolder.updataMicList(list); + Log.i("多人连麦", "onOpenDrawer: "+list.size()); + for (LinkMicUserBean userBean : list) { + Log.i("多人连麦", "u list: "+userBean.toString()); + } + } + break; + case LINK_MIC_UPDATE_AUDIENCE_LIST: + mAudienceList = (List) event.getObject(); + if (micListener != null) { + micListener.updateAudienceList(mAudienceList); + } + break; + case LINK_MIC_CLOSE: + if(manager.mLiveRoomViewHolder!=null){ + manager.mLiveRoomViewHolder.updataCleanMic(); + } + break; } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 87f427b85..f9b61a9a4 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -48,6 +48,7 @@ import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.BitmapUtil; import com.yunbao.common.utils.Bus; @@ -66,7 +67,7 @@ import com.yunbao.live.bean.LiveGuardInfo; import com.yunbao.live.bean.LiveKsyConfigBean; import com.yunbao.live.bean.LiveReceiveGiftBean; import com.yunbao.common.bean.LiveUserGiftBean; -import com.yunbao.live.bean.MicUserBean; +import com.yunbao.common.bean.MicUserBean; import com.yunbao.live.dialog.LiveLinkMicListDialogFragment; import com.yunbao.live.dialog.LiveMicAnchorDialogFragment; import com.yunbao.live.dialog.LiveNewFunctionDialogFragment; @@ -150,8 +151,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl public static int pk_nub; public static int backIndex = 0;//0=未判断,1=已判断 private FaceManager manager; - private TreeMap mMicQueueList = new TreeMap<>(); - private List mAudienceList = new ArrayList<>(); @Override protected int getLayoutId() { @@ -240,7 +239,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl */ int mrr = 0; public int leave = 0; - private LiveMicAnchorDialogFragment.OnMicListener micListener = null; + @Override public void onClick(int functionID) { @@ -393,18 +392,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl } } - private void openMicWindow(int index) { - LiveMicAnchorDialogFragment fragment = new LiveMicAnchorDialogFragment(); - Bundle bundle = new Bundle(); - bundle.putString(Constants.LIVE_UID, mLiveUid); - bundle.putString(Constants.STREAM, mStream); - bundle.putString("By", index+""); - fragment.setArguments(bundle); - micListener = fragment.getMicListener(); - fragment.setMicQueueList(mMicQueueList); - fragment.setAudienceList(mAudienceList); - fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment"); - } /** * 主播展示离开直播间 @@ -910,7 +897,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl mLivePushViewHolder = null; mLiveReadyViewHolder = null; mLiveAnchorViewHolder = null; - if(MicStatusManager.getInstance().isAnchorOpenRoom()){ + if (MicStatusManager.getInstance().isAnchorOpenRoom()) { MicStatusManager.getInstance().closeMic(mContext); } L.e("LiveAnchorActivity-------onDestroy------->"); @@ -1363,6 +1350,13 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl if (micListener != null) { micListener.updateMicList(mMicQueueList); } + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.updataMicList(list); + Log.i("多人连麦", "onOpenDrawer: "+list.size()); + for (LinkMicUserBean userBean : list) { + Log.i("多人连麦", "u list: "+userBean.toString()); + } + } break; case LINK_MIC_UPDATE_AUDIENCE_LIST: mAudienceList = (List) event.getObject(); @@ -1370,9 +1364,13 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl micListener.updateAudienceList(mAudienceList); } break; + case LINK_MIC_CLOSE: + if(mLiveRoomViewHolder!=null){ + mLiveRoomViewHolder.updataCleanMic(); + } + break; } } - /** * 检查指定直播间连麦人数 * diff --git a/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java b/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java index 47cea153b..f6a403849 100644 --- a/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java @@ -31,15 +31,11 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; -import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; -import com.yunbao.live.bean.MicUserBean; -import com.yunbao.live.event.LiveRoomChangeEvent; +import com.yunbao.common.bean.MicUserBean; import com.yunbao.live.interfaces.LiveFunctionClickListener; import com.yunbao.live.socket.SocketSendBean; -import org.greenrobot.eventbus.EventBus; - import java.net.MalformedURLException; import java.net.URL; diff --git a/live/src/main/java/com/yunbao/live/adapter/UserMicInfoAdapter.java b/live/src/main/java/com/yunbao/live/adapter/UserMicInfoAdapter.java index f01e0bab5..4bd7681ef 100644 --- a/live/src/main/java/com/yunbao/live/adapter/UserMicInfoAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/UserMicInfoAdapter.java @@ -3,7 +3,6 @@ package com.yunbao.live.adapter; import android.content.Context; import androidx.annotation.NonNull; -import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import android.view.View; @@ -24,7 +23,7 @@ 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.bean.MicUserBean; +import com.yunbao.common.bean.MicUserBean; import java.net.MalformedURLException; import java.net.URL; diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java index 412e4effb..bfb005701 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java @@ -32,7 +32,7 @@ import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.adapter.AnchorUserMicInfoAdapter; import com.yunbao.live.bean.LiveGuardInfo; import com.yunbao.common.bean.LiveUserGiftBean; -import com.yunbao.live.bean.MicUserBean; +import com.yunbao.common.bean.MicUserBean; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.utils.LiveImDeletUtil; import com.yunbao.common.utils.MicStatusManager; diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java index 70d755ca3..e61cc6db6 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java @@ -32,7 +32,7 @@ import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.adapter.UserMicInfoAdapter; import com.yunbao.live.bean.LiveGuardInfo; -import com.yunbao.live.bean.MicUserBean; +import com.yunbao.common.bean.MicUserBean; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.socket.SocketSendBean; import com.yunbao.live.utils.LiveImDeletUtil; diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index b6d6b7c6b..e6e9df4d2 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -193,6 +193,7 @@ public class LiveAudienceEvent extends BaseModel { LINK_MIC_CANCEL(40, "取消连麦"), LINK_MIC_UPDATE_MIC_LIST(41, "更新连麦列表"), LINK_MIC_UPDATE_AUDIENCE_LIST(42, "更新观众/可邀请列表"), + LINK_MIC_CLOSE(43, "主播关闭连麦房"), ; private int type; diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index 2694e3655..9463686b2 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -177,15 +177,16 @@ public class SocketRyClient { EventBus.getDefault().post("UsertoRY"); } else if (actions == 5) { JSONObject mic_data = map.getJSONObject("ct"); - LiveRoomViewHolder.updataMicList(mic_data.getJSONArray("userlist")); - EventBus.getDefault().post(new LiveAudienceEvent() + Bus.get().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) { ToastUtil.show("主播已關閉當前語音連麥功能"); - LiveRoomViewHolder.updataCleanMic(); EventBus.getDefault().post("endMic"); + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CLOSE) + .setObject(map.toJavaObject(LinkMicUserBean.class))); } else if (actions == 8) { ToastUtil.show("您已被移出多人語音連麥"); EventBus.getDefault().post("endMic"); @@ -195,15 +196,14 @@ public class SocketRyClient { .setObject(map.toJavaObject(LinkMicUserBean.class)) ); } else if (actions == 7) {//取消连麦 - EventBus.getDefault().post(new LiveAudienceEvent() + Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CANCEL) - .setObject(map.toJavaObject(LinkMicUserBean.class)) ); } break; case Constants.UP_USER_LIST: mListener.onUpUserList(map.getJSONObject("ct")); - EventBus.getDefault().post(new LiveAudienceEvent() + Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_AUDIENCE_LIST) .setObject(JSON.parseArray(map.getJSONObject("ct").getString("userlist"), LiveUserGiftBean.class)) ); diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index dd6bbce91..eed08e737 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -611,6 +611,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { rcrtcRoom = null; MicStatusManager.getInstance().clear(); ToastUtil.show("已成功退出語音連麥"); + if(onMicCallback!=null){ + onMicCallback.onMikUpdate(); + } } }); } @@ -822,6 +825,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { Log.e("ry", "切换成功"); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { + if(onMicCallback!=null){ + onMicCallback.onMikUpdate(); + } //遍历远端用户列表 for (int i = 0; i < rcrtcRoom.getRemoteUsers().size(); i++) { Log.e("ry", rcrtcRoom.getRemoteUsers().get(i).getUserId() + "收到rcrtcOtherRoom" + rcrtcRoom.getRemoteUsers().size()); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java index 85d216c23..32ad18a89 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java @@ -14,6 +14,8 @@ import com.yunbao.live.interfaces.ILiveLinkMicViewHolder; public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements ILiveLinkMicViewHolder { protected LiveBean mLiveBean; + OnMicCallback onMicCallback;//连麦回调 + public LiveRoomPlayViewHolder(Context context, ViewGroup parentView) { super(context, parentView); } @@ -47,4 +49,18 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL public void setLiveBean(LiveBean data) { this.mLiveBean = data; } + + public OnMicCallback getOnMicCallback() { + return onMicCallback; + } + + public void setOnMicCallback(OnMicCallback onMicCallback) { + this.onMicCallback = onMicCallback; + } + + + public interface OnMicCallback{ + void onMikUpdate(); + + } } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index cfcbe1164..6519973e2 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -64,10 +64,12 @@ import com.yunbao.common.bean.GuardUserModel; import com.yunbao.common.bean.HourRank; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.LevelBean; +import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveGiftBean; import com.yunbao.common.bean.LiveRoomActivityBanner; import com.yunbao.common.bean.LiveUserGiftBean; +import com.yunbao.common.bean.MicUserBean; import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.NewPeopleTaskModel; import com.yunbao.common.bean.PkRankBean; @@ -260,9 +262,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis static ImageView pk5Ico; static RelativeLayout pk5; - static RelativeLayout mic_view; - static RelativeLayout mic_view1; - static RelativeLayout mic_view2; + RelativeLayout mic_view; + RelativeLayout mic_view1; + RelativeLayout mic_view2; static ImageView mic_ico; static RoundedImageView mic_ico1; @@ -340,26 +342,26 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } //更新连麦人 - public static List mic_ids = new ArrayList<>(); + public List mic_ids = new ArrayList<>(); - public static void updataMicList(JSONArray obj) { + public void updataMicList(List list) { mic_ids.clear(); updataCleanMic(); //拿到原始数据 - for (int j = 0; j < obj.size(); j++) { - JSONObject mic = obj.getJSONObject(j); - if (j == 1) { + for (int i = 0; i < list.size(); i++) { + LinkMicUserBean bean=list.get(i); + if(i==1){ mic_view.setVisibility(View.VISIBLE); - mic_ids.add(mic.getString("id")); - ImgLoader.display2(Contexts, mic.getString("avatar"), mic_ico); - } else if (j == 2) { + mic_ids.add(bean.getId()); + ImgLoader.display2(Contexts, bean.getAvatar(), mic_ico); + }else if(i==2){ mic_view1.setVisibility(View.VISIBLE); - mic_ids.add(mic.getString("id")); - ImgLoader.display2(Contexts, mic.getString("avatar"), mic_ico1); - } else if (j == 3) { + mic_ids.add(bean.getId()); + ImgLoader.display2(Contexts, bean.getAvatar(), mic_ico1); + }else if(i==3){ mic_view2.setVisibility(View.VISIBLE); - mic_ids.add(mic.getString("id")); - ImgLoader.display2(Contexts, mic.getString("avatar"), mic_ico2); + mic_ids.add(bean.getId()); + ImgLoader.display2(Contexts, bean.getAvatar(), mic_ico2); } } mic_view.setOnClickListener(new View.OnClickListener() { @@ -382,7 +384,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis }); } - public static void updataCleanMic() { + public void updataCleanMic() { mic_view.setVisibility(View.GONE); mic_view1.setVisibility(View.GONE); mic_view2.setVisibility(View.GONE); diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index c0b649b35..3b2889fa6 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -132,7 +132,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //直播间拆分布局 private LiveRoomPlayViewHolder mLivePlayViewHolder; //头部布局 - private LiveRoomViewHolder mLiveRoomViewHolder; + public LiveRoomViewHolder mLiveRoomViewHolder; //底部布局 public LiveAudienceViewHolder mLiveAudienceViewHolder; //观众与主播连麦逻辑 @@ -265,6 +265,14 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLivePlayViewHolder.setLiveBean(data); mLivePlayViewHolder.setCover(data.getThumb()); mLivePlayViewHolder.play(data.getPull()); + mLivePlayViewHolder.setOnMicCallback(new LiveRoomPlayViewHolder.OnMicCallback() { + @Override + public void onMikUpdate() { + if(mContext instanceof LiveActivity) { + ((LiveActivity) mContext).showMicList(mLiveBean.getUid(),mLiveRoomViewHolder); + } + } + }); mLiveRoomViewHolder.resetView(); mLiveRoomViewHolder.setAvatar(data.getAvatar()); mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); @@ -512,8 +520,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.showLiveRoomActivityBanner(); } }); + if(mContext instanceof LiveActivity) { + ((LiveActivity) mContext).showMicList(mLiveBean.getUid(),mLiveRoomViewHolder); + } } + + public void removeLiveEnd() { if (mLiveAudienceViewHolder != null) {