修复连麦小窗再进直播间会闪退问题

This commit is contained in:
zlzw 2022-11-28 14:52:39 +08:00
parent e6766dc5eb
commit 83039d7b29
12 changed files with 20 additions and 13 deletions

View File

@ -16,6 +16,7 @@ import com.facebook.FacebookSdk;
import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import java.lang.ref.WeakReference;
import java.util.Locale; import java.util.Locale;
import io.rong.imlib.RongIMClient; import io.rong.imlib.RongIMClient;
@ -31,6 +32,7 @@ import me.leolin.shortcutbadger.ShortcutBadger;
public class CommonAppContext extends MultiDexApplication { public class CommonAppContext extends MultiDexApplication {
public static CommonAppContext sInstance; public static CommonAppContext sInstance;
public static WeakReference<Activity> activityWeakReference;
private int mCount; private int mCount;
private boolean mFront;//是否前台 private boolean mFront;//是否前台
public static int jpushMsgNum; public static int jpushMsgNum;
@ -98,6 +100,7 @@ public class CommonAppContext extends MultiDexApplication {
@Override @Override
public void onActivityStarted(Activity activity) { public void onActivityStarted(Activity activity) {
mCount++; mCount++;
activityWeakReference=new WeakReference<>(activity);
if (!mFront) { if (!mFront) {
mFront = true; mFront = true;
L.e("AppContext------->处于前台"); L.e("AppContext------->处于前台");

View File

@ -157,8 +157,12 @@ public class MicStatusManager {
.isDisposed(); .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);
} }
/** /**

View File

@ -186,8 +186,8 @@ public class RouteUtil {
* 打开直播页面 * 打开直播页面
*/ */
public static void forwardLiveAudienceActivity(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) { public static void forwardLiveAudienceActivity(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) {
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(mLiveBean.getUid())){
MicStatusManager.getInstance().showDownMicDialog(CommonAppContext.sInstance); MicStatusManager.getInstance().showDownMicDialog(CommonAppContext.activityWeakReference.get());
return; return;
} }
ARouter.getInstance().build(PATH_LIVE_AUDIENCE) ARouter.getInstance().build(PATH_LIVE_AUDIENCE)

View File

@ -735,7 +735,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (liveBean == null) { if (liveBean == null) {
return; return;
} }
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(liveUid)){
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }

View File

@ -240,7 +240,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
if (liveBean == null) { if (liveBean == null) {
return; return;
} }
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(liveUid)){
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }

View File

@ -620,7 +620,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
if (liveBean == null) { if (liveBean == null) {
return; return;
} }
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(liveUid)){
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }

View File

@ -331,7 +331,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
if (liveBean == null) { if (liveBean == null) {
return; return;
} }
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(liveUid)){
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }

View File

@ -3574,7 +3574,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
.setMicIng(2) .setMicIng(2)
.setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal))); .setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal)));
} else { } else {
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(liveUid)){
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }

View File

@ -260,7 +260,7 @@ public class MyWebViewActivity extends AbsActivity {
} }
if (!"".endsWith(Constants.mStream)) { if (!"".endsWith(Constants.mStream)) {
finish(); finish();
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(liveUid)){
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }

View File

@ -237,7 +237,7 @@ public class MyWebViewActivity2 extends AbsActivity {
} }
if (!"".endsWith(Constants.mStream)) { if (!"".endsWith(Constants.mStream)) {
finish(); finish();
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(liveUid)){
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }

View File

@ -417,7 +417,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
} }
if (!"".endsWith(Constants.mStream)) { if (!"".endsWith(Constants.mStream)) {
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(liveUid)){
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }

View File

@ -775,7 +775,7 @@ public class UserHomeViewHolder2 extends AbsLivePageViewHolder implements LiveSh
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
if (mFromLiveRoom) { if (mFromLiveRoom) {
if(MicStatusManager.getInstance().isMic()){ if(MicStatusManager.getInstance().isMic(liveUid)){
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }