1:修改当在游戏房间的时候,不能点击其他房间进入,
2:在进入房间后,退出上一个房间的各种调用
This commit is contained in:
@@ -40,6 +40,9 @@ public class RoomInfoResp implements Serializable {
|
||||
private SingerInfo singer_info;
|
||||
private SignInfo sign_info;
|
||||
|
||||
private String room_id="";
|
||||
private String msg="";
|
||||
|
||||
//弹出麦位操作弹出
|
||||
public boolean isWheatManager() {
|
||||
//是管理员且在1或者9号麦,当时房主模式时,2号麦也有管理权限
|
||||
|
||||
@@ -137,6 +137,15 @@ public class ConfirmDialog extends Dialog {
|
||||
// 隐藏取消按钮
|
||||
btnNegative.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//判断是否需要显示确认按钮
|
||||
if (positiveButtonText != null && !positiveButtonText.isEmpty()) {
|
||||
btnPositive.setText(positiveButtonText);
|
||||
btnPositive.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
// 隐藏确认按钮
|
||||
btnPositive.setVisibility(View.GONE);
|
||||
}
|
||||
// 倒计时逻辑
|
||||
if (isCountdownEnabled && countdownSeconds > 0) {
|
||||
startCountdown(btnNegative);
|
||||
|
||||
@@ -2249,6 +2249,8 @@ public class RetrofitClient {
|
||||
} else if (roomInfoRespBaseModel.getCode() == 0) {
|
||||
ToastUtils.showShort(roomInfoRespBaseModel.getMsg());
|
||||
observer.onNext(null);
|
||||
}else if (roomInfoRespBaseModel.getCode() == 202){
|
||||
observer.onNext(roomInfoRespBaseModel.getData());
|
||||
} else {
|
||||
MessageListenerSingleton.getInstance().quitGroup(roomId);
|
||||
}
|
||||
|
||||
@@ -3198,6 +3198,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
override fun roomInfo(resp: RoomInfoResp) {
|
||||
if (!isSwitchRoom)
|
||||
return
|
||||
getHour()
|
||||
mRoomInfoResp = resp
|
||||
isOnline = true
|
||||
password = ""
|
||||
@@ -3555,14 +3556,11 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
is RoomHourBean.RoomListBean -> {
|
||||
ClickUtils.clearAllClickRecords()
|
||||
AgoraManager.getInstance().cleanup()
|
||||
roomId = event.room_id
|
||||
isSwitchRoom = true
|
||||
// 重新连接房间相关服务
|
||||
resumeRoomState()
|
||||
publicScreenFragment?.onDestroy()
|
||||
publicScreenFragment = null
|
||||
if (event.room_id== CommonAppContext.getInstance().playId){
|
||||
return
|
||||
}
|
||||
|
||||
roomId2=event.room_id
|
||||
|
||||
MvpPre?.getRoomIn(event.room_id, "")
|
||||
}
|
||||
@@ -3601,6 +3599,19 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
private var roomId2: String? = null //这是点击小时榜后记录的房间id
|
||||
|
||||
private fun getHour(){
|
||||
ClickUtils.clearAllClickRecords()
|
||||
AgoraManager.getInstance().cleanup()
|
||||
roomId = roomId2
|
||||
isSwitchRoom = true
|
||||
// 重新连接房间相关服务
|
||||
resumeRoomState()
|
||||
publicScreenFragment?.onDestroy()
|
||||
publicScreenFragment = null
|
||||
}
|
||||
|
||||
|
||||
private var giftGiveEvent: RoomGiftGiveEvent? = null
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import static com.liulishuo.okdownload.OkDownloadProvider.context;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomContacts;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
@@ -10,6 +13,7 @@ import com.xscm.moduleutil.bean.RoomCharmRankBean;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomOnline;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
import com.xscm.moduleutil.http.APIException;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
@@ -43,26 +47,31 @@ public class RoomPresenter extends BasePresenter<RoomContacts.View> implements R
|
||||
|
||||
@Override
|
||||
public void onNext(RoomInfoResp resp) {
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||
String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||
String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
|
||||
String rtm_token=resp.getUser_info().getAgora_rtm_token();
|
||||
SpUtil.setRtmToken(rtm_token);
|
||||
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||
boolean enableMic = false; // 是否开启麦克风
|
||||
boolean enableJs=false; // 是否开启角色
|
||||
if (resp.getUser_info().getPit_number()!=0){
|
||||
enableJs=true;
|
||||
}
|
||||
LogUtils.e("token",token);
|
||||
LogUtils.e("roomId:",roomId);
|
||||
AgoraManager.getInstance()
|
||||
.joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomInfo(resp);
|
||||
|
||||
if(!resp.getRoom_id().isEmpty()){
|
||||
queren(resp.getRoom_id(),resp.getMsg());
|
||||
}else {
|
||||
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||
String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||
String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
|
||||
String rtm_token = resp.getUser_info().getAgora_rtm_token();
|
||||
SpUtil.setRtmToken(rtm_token);
|
||||
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||
boolean enableMic = false; // 是否开启麦克风
|
||||
boolean enableJs = false; // 是否开启角色
|
||||
if (resp.getUser_info().getPit_number() != 0) {
|
||||
enableJs = true;
|
||||
}
|
||||
LogUtils.e("token", token);
|
||||
LogUtils.e("roomId:", roomId);
|
||||
AgoraManager.getInstance()
|
||||
.joinRoom(token, roomId, uid, enableMic, enableJs);
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomInfo(resp);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
@@ -84,6 +93,21 @@ public class RoomPresenter extends BasePresenter<RoomContacts.View> implements R
|
||||
});
|
||||
}
|
||||
|
||||
private void queren(String roomId,String msg){
|
||||
new ConfirmDialog(ActivityUtils.getTopActivity(),
|
||||
"提示",
|
||||
msg,
|
||||
CommonAppContext.getInstance().playId.equals(roomId) ?"":"去上一个房间",
|
||||
CommonAppContext.getInstance().playId.equals(roomId) ?"取消":"在想想",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
getRoomIn(roomId,"");
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
}, false, 0).show();
|
||||
}
|
||||
|
||||
// TODO: 2025/6/10 在线列表
|
||||
@Override
|
||||
public void getRoomOnline(String roomId, String page, String page_limit) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.xscm.modulemain.manager;
|
||||
|
||||
import static com.liulishuo.okdownload.OkDownloadProvider.context;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -19,6 +21,7 @@ import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomOnline;
|
||||
import com.xscm.moduleutil.bean.room.RoomOnlineBean;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
import com.xscm.moduleutil.event.RoomOutEvent;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
@@ -49,6 +52,8 @@ public class RoomManager {
|
||||
// 房间数据缓存
|
||||
private Map<String, RoomInfoResp> roomDataCache = new ConcurrentHashMap<>();
|
||||
private Map<String, Long> cacheTimestamps = new ConcurrentHashMap<>();
|
||||
private String taskId;
|
||||
private Context context;
|
||||
|
||||
// 缓存有效期(5分钟)
|
||||
private static final long CACHE_DURATION = 5 * 60 * 1000;
|
||||
@@ -71,6 +76,8 @@ public class RoomManager {
|
||||
* @param password 房间密码
|
||||
*/
|
||||
public void fetchRoomDataAndEnter(Context context, String roomId, String password, String taskId) {
|
||||
this.taskId=taskId;
|
||||
this.context=context;
|
||||
// 显示加载提示
|
||||
// 这里可以根据需要添加加载对话框
|
||||
if (CommonAppContext.getInstance().isRoomJoininj) {
|
||||
@@ -85,12 +92,15 @@ public class RoomManager {
|
||||
fetchAndJoinRoom(context, roomId, password, taskId);
|
||||
} else {
|
||||
if (!CommonAppContext.getInstance().playId.equals(roomId)) {
|
||||
MessageListenerSingleton.getInstance().joinGroup(roomId);
|
||||
exitRoom(CommonAppContext.getInstance().playId);
|
||||
CommonAppContext.getInstance().isShow = false;
|
||||
CommonAppContext.getInstance().isPlaying = false;
|
||||
CommonAppContext.getInstance().isRoomJoininj = false;
|
||||
EventBus.getDefault().post(new RoomOutEvent());
|
||||
// MessageListenerSingleton.getInstance().joinGroup(roomId);
|
||||
// exitRoom(CommonAppContext.getInstance().playId);
|
||||
// CommonAppContext.getInstance().isShow = false;
|
||||
// CommonAppContext.getInstance().isPlaying = false;
|
||||
// CommonAppContext.getInstance().isRoomJoininj = false;
|
||||
// EventBus.getDefault().post(new RoomOutEvent());
|
||||
|
||||
fetchAndJoinRoom(context, roomId, password, taskId);
|
||||
return;
|
||||
} else if (CommonAppContext.getInstance().lable_id.equals("6")) {
|
||||
upInfo(context, roomId, password, true, roomInfo, true, taskId);
|
||||
return;
|
||||
@@ -136,24 +146,42 @@ public class RoomManager {
|
||||
@Override
|
||||
public void onNext(RoomInfoResp resp) {
|
||||
if (resp != null) {
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||
String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||
String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
|
||||
String rtm_token = resp.getUser_info().getAgora_rtm_token();
|
||||
SpUtil.setRtmToken(rtm_token);
|
||||
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||
boolean enableMic = false; // 是否开启麦克风
|
||||
boolean enableJs = false; // 是否开启角色
|
||||
if (resp.getUser_info().getPit_number() != 0) {
|
||||
enableJs = true;
|
||||
if (ActivityUtils.getTopActivity() instanceof MainActivity){
|
||||
((MainActivity) ActivityUtils.getTopActivity()).isShowLoading(false);
|
||||
}
|
||||
if (!resp.getRoom_id().isEmpty()){
|
||||
if(CommonAppContext.getInstance().playId==null){
|
||||
CommonAppContext.getInstance().playId="";
|
||||
}
|
||||
queren(resp.getRoom_id(),resp.getMsg());
|
||||
}else {
|
||||
|
||||
MessageListenerSingleton.getInstance().joinGroup(roomId);
|
||||
exitRoom(CommonAppContext.getInstance().playId);
|
||||
CommonAppContext.getInstance().isShow = false;
|
||||
CommonAppContext.getInstance().isPlaying = false;
|
||||
CommonAppContext.getInstance().isRoomJoininj = false;
|
||||
EventBus.getDefault().post(new RoomOutEvent());
|
||||
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||
String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||
String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
|
||||
String rtm_token = resp.getUser_info().getAgora_rtm_token();
|
||||
SpUtil.setRtmToken(rtm_token);
|
||||
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||
boolean enableMic = false; // 是否开启麦克风
|
||||
boolean enableJs = false; // 是否开启角色
|
||||
if (resp.getUser_info().getPit_number() != 0) {
|
||||
enableJs = true;
|
||||
}
|
||||
LogUtils.e("token", token);
|
||||
LogUtils.e("roomId:", roomId);
|
||||
// 初始化 Agora 并加入房间
|
||||
AgoraManager.getInstance()
|
||||
.joinRoom(token, roomId, uid, enableMic, enableJs);
|
||||
cacheRoomData(roomId, resp);
|
||||
navigateToRoom(context, roomId, password, resp, false, taskId);
|
||||
}
|
||||
LogUtils.e("token", token);
|
||||
LogUtils.e("roomId:", roomId);
|
||||
// 初始化 Agora 并加入房间
|
||||
AgoraManager.getInstance()
|
||||
.joinRoom(token, roomId, uid, enableMic, enableJs);
|
||||
cacheRoomData(roomId, resp);
|
||||
navigateToRoom(context, roomId, password, resp, false, taskId);
|
||||
}else {
|
||||
if (ActivityUtils.getTopActivity() instanceof MainActivity){
|
||||
((MainActivity) ActivityUtils.getTopActivity()).isShowLoading(false);
|
||||
@@ -342,4 +370,25 @@ public class RoomManager {
|
||||
|
||||
Logger.d(TAG, "退出房间: " + roomId);
|
||||
}
|
||||
|
||||
private void queren(String roomId,String msg){
|
||||
// 检查context是否有效,避免在Activity销毁后显示对话框
|
||||
// if (context == null || (context instanceof Activity && ((Activity)context).isFinishing())) {
|
||||
// Logger.d(TAG, "Context is null or Activity is finishing, cannot show dialog");
|
||||
// return;
|
||||
// }
|
||||
new ConfirmDialog(ActivityUtils.getTopActivity(),
|
||||
"提示",
|
||||
msg,
|
||||
CommonAppContext.getInstance().playId.equals(roomId) ?"":"去上一个房间",
|
||||
CommonAppContext.getInstance().playId.equals(roomId) ?"取消":"在想想",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
// MvpPre.deleteComment(String.valueOf(commentId));
|
||||
fetchRoomDataAndEnter(ActivityUtils.getTopActivity(),roomId,"",taskId);
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
}, false, 0).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
android:id="@+id/tv_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="51"
|
||||
tools:text="51"
|
||||
android:gravity="left|center"
|
||||
android:textColor="@color/color_FF333333"
|
||||
android:textSize="@dimen/sp_16"/>
|
||||
@@ -83,7 +83,7 @@
|
||||
android:id="@+id/tv_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="51"
|
||||
tools:text="51"
|
||||
android:gravity="left|center"
|
||||
android:textColor="@color/color_FF333333"
|
||||
android:textSize="@dimen/sp_16"/>
|
||||
|
||||
Reference in New Issue
Block a user