优化在连麦中禁止直播间滑动
This commit is contained in:
parent
5cc521d93c
commit
a965a83653
@ -13,6 +13,9 @@ import com.yunbao.common.http.HttpCallback;
|
|||||||
import com.yunbao.common.http.HttpClient;
|
import com.yunbao.common.http.HttpClient;
|
||||||
import com.yunbao.common.http.ResponseModel;
|
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.RCRTCEngine;
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
|
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
|
||||||
@ -32,6 +35,7 @@ public class MicStatusManager {
|
|||||||
private int micStatus;//连麦状态
|
private int micStatus;//连麦状态
|
||||||
private String micLiveId;//主播uid
|
private String micLiveId;//主播uid
|
||||||
private boolean anchorOpenRoom = false;//主播是否开启连麦房
|
private boolean anchorOpenRoom = false;//主播是否开启连麦房
|
||||||
|
private List<OnMicStatusListener> listeners;
|
||||||
|
|
||||||
public static MicStatusManager getInstance() {
|
public static MicStatusManager getInstance() {
|
||||||
if (manager == null) {
|
if (manager == null) {
|
||||||
@ -41,11 +45,27 @@ public class MicStatusManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private 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) {
|
public void setMicData(int micStatus, String micLiveId) {
|
||||||
this.micLiveId = micLiveId;
|
this.micLiveId = micLiveId;
|
||||||
this.micStatus = micStatus;
|
this.micStatus = micStatus;
|
||||||
|
|
||||||
|
for (OnMicStatusListener listener : listeners) {
|
||||||
|
listener.onStart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAnchorOpenRoom() {
|
public boolean isAnchorOpenRoom() {
|
||||||
@ -59,6 +79,9 @@ public class MicStatusManager {
|
|||||||
public void clear() {
|
public void clear() {
|
||||||
micStatus = 0;
|
micStatus = 0;
|
||||||
micLiveId = "";
|
micLiveId = "";
|
||||||
|
for (OnMicStatusListener listener : listeners) {
|
||||||
|
listener.onClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMicStatus() {
|
public int getMicStatus() {
|
||||||
@ -159,6 +182,7 @@ public class MicStatusManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否在连麦中
|
* 判断是否在连麦中
|
||||||
|
*
|
||||||
* @param toUid 目标uid
|
* @param toUid 目标uid
|
||||||
*/
|
*/
|
||||||
public boolean isMic(String toUid) {
|
public boolean isMic(String toUid) {
|
||||||
@ -176,4 +200,10 @@ public class MicStatusManager {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnMicStatusListener {
|
||||||
|
void onStart();
|
||||||
|
|
||||||
|
void onClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,8 +181,19 @@ public class LiveAudienceActivity extends LiveActivity {
|
|||||||
mLiveUid = mLiveBean.getUid();
|
mLiveUid = mLiveBean.getUid();
|
||||||
mStream = mLiveBean.getStream();
|
mStream = mLiveBean.getStream();
|
||||||
initData();
|
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();
|
super.onDestroy();
|
||||||
ImgLoader.clearMemory(this);
|
ImgLoader.clearMemory(this);
|
||||||
overridePendingTransition(0, 0);
|
overridePendingTransition(0, 0);
|
||||||
|
MicStatusManager.getInstance().removeOnMicListener(onMicStatusListener);
|
||||||
Bus.getOff(this);
|
Bus.getOff(this);
|
||||||
L.e("LiveAudienceActivity-------onDestroy------->");
|
L.e("LiveAudienceActivity-------onDestroy------->");
|
||||||
}
|
}
|
||||||
|
@ -220,8 +220,21 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
//直播页面背景
|
//直播页面背景
|
||||||
liveBack = mRootContainer.findViewById(R.id.live_back);
|
liveBack = mRootContainer.findViewById(R.id.live_back);
|
||||||
mask = mRootContainer.findViewById(R.id.mask);
|
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
|
@Override
|
||||||
public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) {
|
public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) {
|
||||||
isEnterRoom = false;
|
isEnterRoom = false;
|
||||||
@ -708,7 +721,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
MicStatusManager.getInstance().removeOnMicListener(micStatusListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user