From 4eb9adad784608bd49a3e7fcac67708cc7da80a5 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 25 Nov 2022 17:48:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A3=80=E6=B5=8B=E8=BF=9E?= =?UTF-8?q?=E9=BA=A6=E5=AF=B9=E8=AF=9D=E6=A1=86=E4=BD=8D=E7=BD=AE=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E5=A4=84=E9=97=AA=E9=80=80=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/bean/LiveUserGiftBean.java | 3 ++- .../yunbao/common}/utils/MicStatusManager.java | 18 +++++++++++++++--- .../com/yunbao/common/utils/RouteUtil.java | 5 +++++ .../live/activity/LiveAudienceActivity.java | 10 ++-------- .../live/activity/LiveRyAnchorActivity.java | 2 +- .../live/adapter/AnchorUserMicInfoAdapter.java | 2 +- .../live/dialog/LiveHDDialogFragment.java | 5 +++++ .../dialog/LiveMicAnchorDialogFragment.java | 2 +- .../live/dialog/LiveMicUserDialogFragment.java | 2 +- .../live/dialog/SidebarLiveAudience.java | 3 +-- .../live/views/LivePlayRyViewHolder.java | 4 +--- .../yunbao/live/views/LiveRoomViewHolder.java | 16 +--------------- .../yunbao/live/views/PortraitLiveManager.java | 4 +++- 13 files changed, 39 insertions(+), 37 deletions(-) rename {live/src/main/java/com/yunbao/live => common/src/main/java/com/yunbao/common}/utils/MicStatusManager.java (91%) diff --git a/common/src/main/java/com/yunbao/common/bean/LiveUserGiftBean.java b/common/src/main/java/com/yunbao/common/bean/LiveUserGiftBean.java index d68617c3e..51ded39f5 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveUserGiftBean.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveUserGiftBean.java @@ -18,7 +18,8 @@ public class LiveUserGiftBean extends UserBean { private int guardType; private int nub; - + public LiveUserGiftBean() { + } public int getNub() { return nub; diff --git a/live/src/main/java/com/yunbao/live/utils/MicStatusManager.java b/common/src/main/java/com/yunbao/common/utils/MicStatusManager.java similarity index 91% rename from live/src/main/java/com/yunbao/live/utils/MicStatusManager.java rename to common/src/main/java/com/yunbao/common/utils/MicStatusManager.java index 002f5dd56..7431e007a 100644 --- a/live/src/main/java/com/yunbao/live/utils/MicStatusManager.java +++ b/common/src/main/java/com/yunbao/common/utils/MicStatusManager.java @@ -1,5 +1,6 @@ -package com.yunbao.live.utils; +package com.yunbao.common.utils; +import android.app.Dialog; import android.content.Context; import android.os.Handler; import android.os.Looper; @@ -11,7 +12,6 @@ import com.yunbao.common.http.API; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.ResponseModel; -import com.yunbao.common.utils.ToastUtil; import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; @@ -31,7 +31,7 @@ public class MicStatusManager { private static MicStatusManager manager; private int micStatus;//连麦状态 private String micLiveId;//主播uid - private boolean anchorOpenRoom = false; + private boolean anchorOpenRoom = false;//主播是否开启连麦房 public static MicStatusManager getInstance() { if (manager == null) { @@ -160,4 +160,16 @@ public class MicStatusManager { public boolean isMic() { return micStatus == MIC_TYPE_OPEN; } + + /** + * 显示退出连麦状态对话框 + */ + public void showDownMicDialog(Context context) { + DialogUitl.showSimpleDialog(context, "當前正在連麥中,是否退出連麥", new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + downMic(); + } + }); + } } diff --git a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index ec29fff8a..f4aab894e 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -5,6 +5,7 @@ import android.content.Intent; import com.alibaba.android.arouter.launcher.ARouter; import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; import com.yunbao.common.HtmlConfig; import com.yunbao.common.bean.LiveBean; @@ -185,6 +186,10 @@ public class RouteUtil { * 打开直播页面 */ public static void forwardLiveAudienceActivity(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) { + if(MicStatusManager.getInstance().isMic()){ + MicStatusManager.getInstance().showDownMicDialog(CommonAppContext.sInstance); + return; + } ARouter.getInstance().build(PATH_LIVE_AUDIENCE) .withBoolean(Constants.NEW_ENTER_ROOM, false) .withParcelable(Constants.LIVE_BEAN, mLiveBean) 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 ce7189271..c221bcdc1 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -92,7 +92,7 @@ import com.yunbao.live.http.ImHttpUtil; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; -import com.yunbao.live.utils.MicStatusManager; +import com.yunbao.common.utils.MicStatusManager; import com.yunbao.live.views.LiveRoomPlayViewHolder; import com.yunbao.live.views.PortraitLiveManager; @@ -1211,13 +1211,7 @@ public class LiveAudienceActivity extends LiveActivity { int liveTypeVal, String key, Map map, int position, int liveSdk) { if (MicStatusManager.getInstance().getMicStatus() != MicStatusManager.MIC_TYPE_DEFAULT && !MicStatusManager.getInstance().getMicLiveId().equals(liveBean.getUid())) { - Log.i("连麦",MicStatusManager.getInstance().toString()+" | "+liveBean.getUid()); - DialogUitl.showSimpleDialog(context, "當前正在連麥中,是否退出連麥", new DialogUitl.SimpleCallback() { - @Override - public void onConfirmClick(Dialog dialog, String content) { - MicStatusManager.getInstance().downMic(); - } - }); + MicStatusManager.getInstance().showDownMicDialog(context); return; } Intent intent = new Intent(context, LiveAudienceActivity.class); 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 6414e6868..bc5bdbf42 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -85,7 +85,7 @@ import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter; import com.yunbao.live.socket.SocketRyChatUtil; import com.yunbao.live.socket.SocketRyClient; import com.yunbao.live.socket.SocketSendBean; -import com.yunbao.live.utils.MicStatusManager; +import com.yunbao.common.utils.MicStatusManager; import com.yunbao.live.views.LiveEndViewHolder; import com.yunbao.live.views.LiveMusicViewHolder; import com.yunbao.live.views.LiveNewReadyRyViewHolder; 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 7a360013f..1e343adea 100644 --- a/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java @@ -126,7 +126,7 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter { @Override public void onClick(int length) { //只允许最多3人连麦(加主播4人) - if (length < 4) { + if (length <= 4) { if (tag.getType() == TYPE_MIC_REQUEST) { applyMic(tag, 4, createSocketSendBean()); } else if (tag.getType() == TYPE_MIC_INVITE) { diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java index f89194d4d..6d97e8115 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -37,6 +37,7 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; +import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; @@ -242,6 +243,10 @@ public class LiveHDDialogFragment extends AbsDialogFragment { return; } dismiss(); + if(MicStatusManager.getInstance().isMic()){ + MicStatusManager.getInstance().showDownMicDialog(mContext); + return; + } EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, liveTypeVal)); } 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 94dea4944..412e4effb 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveMicAnchorDialogFragment.java @@ -35,7 +35,7 @@ import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.live.bean.MicUserBean; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.utils.LiveImDeletUtil; -import com.yunbao.live.utils.MicStatusManager; +import com.yunbao.common.utils.MicStatusManager; import java.util.ArrayList; import java.util.Arrays; 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 3acc094c5..70d755ca3 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveMicUserDialogFragment.java @@ -36,7 +36,7 @@ import com.yunbao.live.bean.MicUserBean; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.socket.SocketSendBean; import com.yunbao.live.utils.LiveImDeletUtil; -import com.yunbao.live.utils.MicStatusManager; +import com.yunbao.common.utils.MicStatusManager; import org.greenrobot.eventbus.EventBus; diff --git a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java index a9fcb02f9..5ad1c1504 100644 --- a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java +++ b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java @@ -20,8 +20,7 @@ import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; -import com.yunbao.live.utils.MicStatusManager; -import com.yunbao.live.views.LivePlayRyViewHolder; +import com.yunbao.common.utils.MicStatusManager; import org.greenrobot.eventbus.EventBus; 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 9b6020c81..20277c28a 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -17,7 +17,6 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.RelativeLayout; -import com.alibaba.fastjson.JSON; import com.lzy.okserver.OkDownload; import com.lzy.okserver.download.DownloadTask; import com.tencent.live2.V2TXLiveDef; @@ -26,7 +25,6 @@ import com.tencent.live2.V2TXLivePlayerObserver; import com.tencent.live2.impl.V2TXLivePlayerImpl; import com.tencent.rtmp.ui.TXCloudVideoView; import com.yunbao.common.glide.ImgLoader; -import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.utils.DialogUitl; @@ -37,7 +35,7 @@ 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.utils.MicStatusManager; +import com.yunbao.common.utils.MicStatusManager; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; 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 e9981e70a..4fa16ee59 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -138,7 +138,7 @@ import com.yunbao.live.presenter.LiveEnterRoomAnimPresenter; import com.yunbao.live.presenter.LiveGiftAnimPresenter; import com.yunbao.live.presenter.LiveLightAnimPresenter; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; -import com.yunbao.live.utils.MicStatusManager; +import com.yunbao.common.utils.MicStatusManager; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -2094,20 +2094,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } getIsHot(); - getGuardInfo(); - } - - private void getGuardInfo() { - LiveHttpUtil.getUserList(mLiveUid, mStream, "guard", 1, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - JSONObject json = JSONObject.parseObject(info[0]); - JSONArray userlist = json.getJSONArray("userlist"); - if (userlist.size() != 0) { - setGuardIcon(JSONArray.parseArray(userlist.toJSONString(), LiveUserGiftBean.class).get(0)); - } - } - }); } private void setGuardIcon(LiveUserGiftBean guard) { 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 d6de73b49..d6c82641e 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -88,7 +88,7 @@ import com.yunbao.live.socket.SocketRyChatUtil; import com.yunbao.live.socket.SocketRyClient; import com.yunbao.live.socket.SocketSendBean; import com.yunbao.live.utils.LiveImDeletUtil; -import com.yunbao.live.utils.MicStatusManager; +import com.yunbao.common.utils.MicStatusManager; import org.greenrobot.eventbus.EventBus; @@ -457,6 +457,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.setGuardIcon(data.getGuardUserAvatar()); //在线列表 mLiveRoomViewHolder.setUserList(data.getEnterRoomInfo().getUserlists()); + //设置直播信息 + mLiveRoomViewHolder.setLiveInfo(mLiveBean.getUid(), mLiveBean.getStream(), Integer.parseInt(data.getEnterRoomInfo().getUserlistTime()) * 4000); List bannerBeans = new ArrayList<>(); //心愿单 if (data.getWishList().getWishList().size() > 0) {