优化在连麦中禁止直播间滑动

This commit is contained in:
zlzw 2022-11-30 10:18:54 +08:00
parent 5cc521d93c
commit a965a83653
3 changed files with 57 additions and 2 deletions

View File

@ -13,6 +13,9 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.ResponseModel;
import java.util.ArrayList;
import java.util.List;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
@ -32,6 +35,7 @@ public class MicStatusManager {
private int micStatus;//连麦状态
private String micLiveId;//主播uid
private boolean anchorOpenRoom = false;//主播是否开启连麦房
private List<OnMicStatusListener> listeners;
public static MicStatusManager getInstance() {
if (manager == null) {
@ -41,11 +45,27 @@ public class MicStatusManager {
}
private MicStatusManager() {
listeners = new ArrayList<>();
}
/**
* 连麦状态监听器申请连麦中触发onStart退出连麦触发onClose
*/
public void addOnMicListener(OnMicStatusListener listener) {
listeners.add(listener);
}
public void removeOnMicListener(OnMicStatusListener listener) {
listeners.remove(listener);
}
public void setMicData(int micStatus, String micLiveId) {
this.micLiveId = micLiveId;
this.micStatus = micStatus;
for (OnMicStatusListener listener : listeners) {
listener.onStart();
}
}
public boolean isAnchorOpenRoom() {
@ -59,6 +79,9 @@ public class MicStatusManager {
public void clear() {
micStatus = 0;
micLiveId = "";
for (OnMicStatusListener listener : listeners) {
listener.onClose();
}
}
public int getMicStatus() {
@ -159,6 +182,7 @@ public class MicStatusManager {
/**
* 判断是否在连麦中
*
* @param toUid 目标uid
*/
public boolean isMic(String toUid) {
@ -172,8 +196,14 @@ public class MicStatusManager {
DialogUitl.showSimpleDialog(context, "當前正在連麥中", new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
// downMic(); //不做下麦跳转
// downMic(); //不做下麦跳转
}
});
}
public interface OnMicStatusListener {
void onStart();
void onClose();
}
}

View File

@ -181,8 +181,19 @@ public class LiveAudienceActivity extends LiveActivity {
mLiveUid = mLiveBean.getUid();
mStream = mLiveBean.getStream();
initData();
MicStatusManager.getInstance().addOnMicListener(onMicStatusListener);
}
private final MicStatusManager.OnMicStatusListener onMicStatusListener=new MicStatusManager.OnMicStatusListener() {
@Override
public void onStart() {
verticalViewPager.setEnableScroll(false);
}
@Override
public void onClose() {
verticalViewPager.setEnableScroll(true);
}
};
/**
* 初始化界面
*/
@ -530,6 +541,7 @@ public class LiveAudienceActivity extends LiveActivity {
super.onDestroy();
ImgLoader.clearMemory(this);
overridePendingTransition(0, 0);
MicStatusManager.getInstance().removeOnMicListener(onMicStatusListener);
Bus.getOff(this);
L.e("LiveAudienceActivity-------onDestroy------->");
}

View File

@ -220,8 +220,21 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//直播页面背景
liveBack = mRootContainer.findViewById(R.id.live_back);
mask = mRootContainer.findViewById(R.id.mask);
MicStatusManager.getInstance().addOnMicListener(micStatusListener);
}
private final MicStatusManager.OnMicStatusListener micStatusListener = new MicStatusManager.OnMicStatusListener() {
@Override
public void onStart() {
mViewPager.setCanScroll(false);
}
@Override
public void onClose() {
mViewPager.setCanScroll(true);
}
};
@Override
public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) {
isEnterRoom = false;
@ -708,7 +721,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onDestroy() {
MicStatusManager.getInstance().removeOnMicListener(micStatusListener);
}
@Override