From 83039d7b29254d5e713915f5dd798978eb5a4463 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 28 Nov 2022 14:52:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9E=E9=BA=A6=E5=B0=8F?= =?UTF-8?q?=E7=AA=97=E5=86=8D=E8=BF=9B=E7=9B=B4=E6=92=AD=E9=97=B4=E4=BC=9A?= =?UTF-8?q?=E9=97=AA=E9=80=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/yunbao/common/CommonAppContext.java | 3 +++ .../java/com/yunbao/common/utils/MicStatusManager.java | 8 ++++++-- .../src/main/java/com/yunbao/common/utils/RouteUtil.java | 4 ++-- .../com/yunbao/live/activity/LiveAudienceActivity.java | 2 +- .../java/com/yunbao/live/dialog/LiveHDDialogFragment.java | 2 +- .../com/yunbao/live/dialog/LiveUserDialogFragment.java | 2 +- .../java/com/yunbao/live/views/LiveEndViewHolder.java | 2 +- .../java/com/yunbao/live/views/LiveRoomViewHolder.java | 2 +- .../java/com/yunbao/main/activity/MyWebViewActivity.java | 2 +- .../java/com/yunbao/main/activity/MyWebViewActivity2.java | 2 +- .../com/yunbao/main/views/MainHomeLiveViewHolder.java | 2 +- .../java/com/yunbao/main/views/UserHomeViewHolder2.java | 2 +- 12 files changed, 20 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/CommonAppContext.java b/common/src/main/java/com/yunbao/common/CommonAppContext.java index 45973c2f7..f511106fc 100644 --- a/common/src/main/java/com/yunbao/common/CommonAppContext.java +++ b/common/src/main/java/com/yunbao/common/CommonAppContext.java @@ -16,6 +16,7 @@ import com.facebook.FacebookSdk; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.utils.L; +import java.lang.ref.WeakReference; import java.util.Locale; import io.rong.imlib.RongIMClient; @@ -31,6 +32,7 @@ import me.leolin.shortcutbadger.ShortcutBadger; public class CommonAppContext extends MultiDexApplication { public static CommonAppContext sInstance; + public static WeakReference activityWeakReference; private int mCount; private boolean mFront;//是否前台 public static int jpushMsgNum; @@ -98,6 +100,7 @@ public class CommonAppContext extends MultiDexApplication { @Override public void onActivityStarted(Activity activity) { mCount++; + activityWeakReference=new WeakReference<>(activity); if (!mFront) { mFront = true; L.e("AppContext------->处于前台"); 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 7431e007a..be60682b1 100644 --- a/common/src/main/java/com/yunbao/common/utils/MicStatusManager.java +++ b/common/src/main/java/com/yunbao/common/utils/MicStatusManager.java @@ -157,8 +157,12 @@ public class MicStatusManager { .isDisposed(); } - public boolean isMic() { - return micStatus == MIC_TYPE_OPEN; + /** + * 判断是否在连麦中 + * @param toUid 目标uid + */ + public boolean isMic(String toUid) { + return micStatus == MIC_TYPE_OPEN && !micLiveId.equals(toUid); } /** 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 f4aab894e..8a8351275 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -186,8 +186,8 @@ public class RouteUtil { * 打开直播页面 */ public static void forwardLiveAudienceActivity(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) { - if(MicStatusManager.getInstance().isMic()){ - MicStatusManager.getInstance().showDownMicDialog(CommonAppContext.sInstance); + if(MicStatusManager.getInstance().isMic(mLiveBean.getUid())){ + MicStatusManager.getInstance().showDownMicDialog(CommonAppContext.activityWeakReference.get()); return; } ARouter.getInstance().build(PATH_LIVE_AUDIENCE) 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 a2c56a261..e7b9b26c1 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -735,7 +735,7 @@ public class LiveAudienceActivity extends LiveActivity { if (liveBean == null) { return; } - if(MicStatusManager.getInstance().isMic()){ + if(MicStatusManager.getInstance().isMic(liveUid)){ MicStatusManager.getInstance().showDownMicDialog(mContext); return; } 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 26e884bc9..1c89a48de 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -240,7 +240,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment { if (liveBean == null) { return; } - if(MicStatusManager.getInstance().isMic()){ + if(MicStatusManager.getInstance().isMic(liveUid)){ MicStatusManager.getInstance().showDownMicDialog(mContext); return; } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java index 5f819d406..dad1ae9d1 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -620,7 +620,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On if (liveBean == null) { return; } - if(MicStatusManager.getInstance().isMic()){ + if(MicStatusManager.getInstance().isMic(liveUid)){ MicStatusManager.getInstance().showDownMicDialog(mContext); return; } diff --git a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java index 8215d9fd9..c4184c514 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java @@ -331,7 +331,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList if (liveBean == null) { return; } - if(MicStatusManager.getInstance().isMic()){ + if(MicStatusManager.getInstance().isMic(liveUid)){ MicStatusManager.getInstance().showDownMicDialog(mContext); return; } 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 2207486a3..fdf6ef775 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -3574,7 +3574,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis .setMicIng(2) .setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal))); } else { - if(MicStatusManager.getInstance().isMic()){ + if(MicStatusManager.getInstance().isMic(liveUid)){ MicStatusManager.getInstance().showDownMicDialog(mContext); return; } diff --git a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java index 7130d9fd6..7abae3bd7 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java @@ -260,7 +260,7 @@ public class MyWebViewActivity extends AbsActivity { } if (!"".endsWith(Constants.mStream)) { finish(); - if(MicStatusManager.getInstance().isMic()){ + if(MicStatusManager.getInstance().isMic(liveUid)){ MicStatusManager.getInstance().showDownMicDialog(mContext); return; } diff --git a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java index 22fe286e2..9e24bab30 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java @@ -237,7 +237,7 @@ public class MyWebViewActivity2 extends AbsActivity { } if (!"".endsWith(Constants.mStream)) { finish(); - if(MicStatusManager.getInstance().isMic()){ + if(MicStatusManager.getInstance().isMic(liveUid)){ MicStatusManager.getInstance().showDownMicDialog(mContext); return; } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java index 2339e012c..ec2e5ec63 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java @@ -417,7 +417,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); } if (!"".endsWith(Constants.mStream)) { - if(MicStatusManager.getInstance().isMic()){ + if(MicStatusManager.getInstance().isMic(liveUid)){ MicStatusManager.getInstance().showDownMicDialog(mContext); return; } diff --git a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java index b2551ec5f..66553bcb2 100644 --- a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java +++ b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java @@ -775,7 +775,7 @@ public class UserHomeViewHolder2 extends AbsLivePageViewHolder implements LiveSh public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { if (mFromLiveRoom) { - if(MicStatusManager.getInstance().isMic()){ + if(MicStatusManager.getInstance().isMic(liveUid)){ MicStatusManager.getInstance().showDownMicDialog(mContext); return; }