合并PK
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
package com.xscm.moduleutil;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BaseEvent {
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class RoomMessageEvent {
|
||||
private int count;//排麦模式下的人数
|
||||
private int step ; //1:等待邂逅 2:心动连线 3:牵手良缘
|
||||
private int friend_id; //场次id
|
||||
// private List<FriendInfo.HeartList> list;//交友心动值发生变化
|
||||
// private List<FriendInfo.HeartList> list;//交友心动值发生变化
|
||||
private List<UserInfo> list;//交友房麦位发生变化 //推送的事麦上用户信息,这里使用了userinfo接收的
|
||||
|
||||
private FriendUserBean friend_user;//这是推送过来需要卡关系的数据
|
||||
@@ -96,6 +96,7 @@ public class RoomMessageEvent {
|
||||
private String redpacket_id;
|
||||
|
||||
private EmotionDeatils emoji;
|
||||
private String is_pk;//是否是pk
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -18,4 +18,5 @@ public class PkRoomInfo implements Serializable {
|
||||
private String pk_room_value;//对方房间的pk值
|
||||
private String pk_part;;//2:等待开始、3:进行中、4:惩罚阶段
|
||||
private String pk_end_times;
|
||||
private String receive_pk_user_id;//接受pk的用户id
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class RoomInfoResp implements Serializable {
|
||||
public class GiftXlh implements Serializable{
|
||||
private XlhInfo xlh_info ;
|
||||
}
|
||||
@Data
|
||||
@Data
|
||||
public class XlhInfo implements Serializable{
|
||||
private String activities_name;
|
||||
private String icon;
|
||||
|
||||
@@ -4,11 +4,13 @@ import com.xscm.moduleutil.BaseEvent;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false) // 明确不调用父类(Any)的实现
|
||||
public class RoomUserJoinModel extends BaseEvent {
|
||||
|
||||
private String room_id;
|
||||
|
||||
@@ -4,11 +4,13 @@ import com.xscm.moduleutil.BaseEvent;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false) // 明确不调用父类(Any)的实现
|
||||
public class RoomBanWheatEvent extends BaseEvent {
|
||||
|
||||
private String roomId;
|
||||
|
||||
@@ -4,11 +4,13 @@ import com.xscm.moduleutil.BaseEvent;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false) // 明确不调用父类(Any)的实现
|
||||
public class RoomBeckoningEvent extends BaseEvent {
|
||||
|
||||
private String roomId;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.xscm.moduleutil.BaseEvent;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
/**
|
||||
*@author qx
|
||||
@@ -13,6 +14,7 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false) // 明确不调用父类(Any)的实现
|
||||
public class RoomJoinMountModel extends BaseEvent {
|
||||
|
||||
private String room_id;
|
||||
|
||||
@@ -1,28 +1,34 @@
|
||||
package com.xscm.moduleutil.rtc;
|
||||
|
||||
|
||||
import static com.blankj.utilcode.util.SnackbarUtils.getView;
|
||||
import static io.agora.rtc2.video.VideoEncoderConfiguration.*;
|
||||
import static io.agora.rtc2.video.VideoEncoderConfiguration.FRAME_RATE.FRAME_RATE_FPS_15;
|
||||
import static io.agora.rtc2.video.VideoEncoderConfiguration.ORIENTATION_MODE.ORIENTATION_MODE_FIXED_LANDSCAPE;
|
||||
import static io.agora.rtc2.video.VideoEncoderConfiguration.STANDARD_BITRATE;
|
||||
import static io.agora.rtc2.video.VideoEncoderConfiguration.VD_1280x720;
|
||||
import static io.agora.rtc2.video.VideoEncoderConfiguration.FRAME_RATE.FRAME_RATE_FPS_30;
|
||||
import static io.agora.rtc2.video.VideoEncoderConfiguration.ORIENTATION_MODE.*;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.SensorManager;
|
||||
import android.media.projection.MediaProjection;
|
||||
import android.media.projection.MediaProjectionManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.OrientationEventListener;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import android.view.WindowManager;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.PathUtils;
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.blankj.utilcode.util.*;
|
||||
import com.liulishuo.okdownload.DownloadTask;
|
||||
import com.liulishuo.okdownload.StatusUtil;
|
||||
import com.liulishuo.okdownload.core.cause.EndCause;
|
||||
@@ -39,12 +45,15 @@ import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.utils.Md5Utils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.logger.Logger;
|
||||
//import com.tencent.bugly.idasc.crashreport.CrashReport;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@@ -74,7 +83,7 @@ import io.agora.rtc2.video.VideoEncoderConfiguration;
|
||||
public class AgoraManager {
|
||||
|
||||
private static volatile AgoraManager instance;
|
||||
private static RtcEngineEx rtcEngine;
|
||||
public static RtcEngineEx rtcEngine;
|
||||
// private RtcEngineEx rtcEngineEx;
|
||||
private static Context context;
|
||||
private boolean isLocalAudioEnabled = true; // 默认开启麦克风
|
||||
@@ -93,6 +102,16 @@ public class AgoraManager {
|
||||
private String pkRoomId = "";
|
||||
private static String lastRoomId;
|
||||
|
||||
public int pkUserId;
|
||||
|
||||
public int getPkUserId() {
|
||||
return pkUserId;
|
||||
}
|
||||
|
||||
public void setPkUserId(int pkUserId) {
|
||||
this.pkUserId = pkUserId;
|
||||
}
|
||||
|
||||
public void setLastRoomId(String value) {
|
||||
lastRoomId = value;
|
||||
}
|
||||
@@ -103,6 +122,8 @@ public class AgoraManager {
|
||||
}
|
||||
|
||||
private AgoraManager() {
|
||||
// this.context = context.getApplicationContext();
|
||||
// init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
|
||||
}
|
||||
|
||||
@@ -112,6 +133,8 @@ public class AgoraManager {
|
||||
if (instance == null) {
|
||||
instance = new AgoraManager();
|
||||
context = con.getApplicationContext(); // 使用ApplicationContext避免内存泄漏
|
||||
// init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
// init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,6 +172,7 @@ public class AgoraManager {
|
||||
if (rtcEngine != null) {
|
||||
return;
|
||||
}
|
||||
;
|
||||
|
||||
synchronized (AgoraManager.class) {
|
||||
if (rtcEngine != null) {
|
||||
@@ -198,19 +222,25 @@ public class AgoraManager {
|
||||
Log.w("AgoraManager", "Failed to set parameters", e);
|
||||
}
|
||||
|
||||
/*Enable video module*/
|
||||
rtcEngine.enableVideo();
|
||||
|
||||
/*Set up to play remote sound with receiver*/
|
||||
rtcEngine.setDefaultAudioRoutetoSpeakerphone(true);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e("AgoraManager", "Failed to configure RtcEngine", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int calculateScreenAngle(int orientation) {
|
||||
if (orientation >= 315 || orientation < 45) {
|
||||
return 0; // 竖屏(0度)
|
||||
} else if (orientation >= 45 && orientation < 135) {
|
||||
return 90; // 横屏右(90度)
|
||||
} else if (orientation >= 135 && orientation < 225) {
|
||||
return 180; // 倒竖屏(180度)
|
||||
} else {
|
||||
return 270; // 横屏左(270度)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 加入语音聊天房间
|
||||
*/
|
||||
@@ -301,6 +331,19 @@ public class AgoraManager {
|
||||
*/
|
||||
private static IRtcEngineEventHandler getDefaultEventHandler() {
|
||||
return new IRtcEngineEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onRemoteAudioStateChanged(int uid, int state, int reason, int elapsed) {
|
||||
super.onRemoteAudioStateChanged(uid, state, reason, elapsed);
|
||||
LogUtils.e("onRemoteAudioStateChanged", "uid------>" + uid, "state------>" + state, "reason------>" + reason, "elapsed------>" + elapsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserMuteAudio(int uid, boolean muted) {
|
||||
super.onUserMuteAudio(uid, muted);
|
||||
LogUtils.e("onUserMuteAudio", "uid------>" + uid, "muted------>" + muted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
|
||||
|
||||
@@ -312,13 +355,53 @@ public class AgoraManager {
|
||||
}
|
||||
musicContentCenter = IAgoraMusicContentCenter.create(rtcEngine);
|
||||
contentCenterConfiguration = new MusicContentCenterConfiguration();
|
||||
// 已开启音乐内容中心项目的 App ID
|
||||
// 已开启音乐内容中心项目的 App ID
|
||||
contentCenterConfiguration.appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||
// 使用音乐内容中心的用户 ID。该 ID 可以和你加入 RTC 频道时使用的 uid 一致,但不能为 0
|
||||
// 使用音乐内容中心的用户 ID。该 ID 可以和你加入 RTC 频道时使用的 uid 一致,但不能为 0
|
||||
contentCenterConfiguration.mccUid = uid;
|
||||
// 填入用于鉴权的 Token
|
||||
// 填入用于鉴权的 Token
|
||||
contentCenterConfiguration.token = SpUtil.getRtmToken();
|
||||
|
||||
// 创建 IAgoraMusicContentCenterEventHandler,用于 SDK 向客户端发送音乐内容中心事件通知
|
||||
// contentCenterConfiguration.eventHandler = new IMusicContentCenterEventHandler() {
|
||||
// @Override
|
||||
// public void onPreLoadEvent(String requestId, long songCode, int percent, String lyricUrl, int status, int errorCode) {
|
||||
// LogUtils.e("@@@1", "requestId: " + requestId + ", songCode: " + songCode + ", percent: " + percent + ", lyricUrl: " + lyricUrl + ", status: " + status + ", errorCode: " + errorCode);
|
||||
// if (!lyricUrl.isEmpty() && percent == 100 && !isBjMusic) {
|
||||
// getLyricsInstance(lyricUrl);
|
||||
// }
|
||||
//// musicPlayer.open(songCode, 0);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMusicCollectionResult(String requestId, int page, int pageSize, int total, Music[] list, int errorCode) {
|
||||
// LogUtils.e("@@@2", "requestId: " + requestId + ", page: " + page + ", pageSize: " + pageSize + ", total: " + total);
|
||||
// MusicBean musicBean = new MusicBean();
|
||||
// musicBean.setMusicList(Arrays.asList(list));
|
||||
// musicBean.setPage(page);
|
||||
// EventBus.getDefault().post(musicBean);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMusicChartsResult(String requestId, MusicChartInfo[] list, int errorCode) {
|
||||
// LogUtils.e("@@@", "requestId: " + requestId);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onLyricResult(String requestId, long songCode, String lyricUrl, int errorCode) {
|
||||
// LogUtils.e("@@@22", "requestId: " + requestId + ", songCode: " + songCode + ", lyricUrl: " + lyricUrl + ", errorCode: " + errorCode);
|
||||
// if (lyricUrl != null && !isBjMusic) {
|
||||
// getLyricsInstance(lyricUrl);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSongSimpleInfoResult(String requestId, long songCode, String simpleInfo, int errorCode) {
|
||||
// LogUtils.e("@@@", "requestId: " + requestId + ", songCode: " + songCode + ", simpleInfo: " + simpleInfo + ", errorCode: " + errorCode);
|
||||
// }
|
||||
// };
|
||||
// 初始化 IAgoraMusicContentCenter
|
||||
|
||||
musicContentCenter.initialize(contentCenterConfiguration);
|
||||
if (musicPlayer != null) {
|
||||
musicPlayer = null;
|
||||
@@ -333,6 +416,12 @@ public class AgoraManager {
|
||||
// getLyricsInstance(lyricUrl);
|
||||
}
|
||||
LogUtils.e("AgoraManager", "isPreload2: " + songCode, "percent: " + percent);
|
||||
|
||||
// if (!lyricUrl.isEmpty() && percent == 100 && !isBjMusic) {
|
||||
// musicPlayer.stop();
|
||||
// musicPlayer.open(songCode, 0);
|
||||
//// getLyricsInstance(lyricUrl);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -384,6 +473,13 @@ public class AgoraManager {
|
||||
|
||||
@Override
|
||||
public void onUserJoined(int uid, int elapsed) {//远端用户加入频道
|
||||
// for (IRtcEngineEventHandler handler : eventHandlers) {
|
||||
// if (handler != null) {
|
||||
// handler.onUserJoined(uid, elapsed);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
for (SoundLevelUpdateListener listener : soundLevelUpdateListeners) {
|
||||
if (listener != null) {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
@@ -404,13 +500,19 @@ public class AgoraManager {
|
||||
|
||||
@Override
|
||||
public void onUserOffline(int uid, int reason) {//远端用户离开频道
|
||||
// for (IRtcEngineEventHandler handler : eventHandlers) {
|
||||
// if (handler != null) {
|
||||
// handler.onUserOffline(uid, reason);
|
||||
// }
|
||||
for (SoundLevelUpdateListener listener : soundLevelUpdateListeners) {
|
||||
if (listener != null) {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
// 远程用户音量变化
|
||||
listener.userOffline(uid, reason);
|
||||
// }
|
||||
});
|
||||
}
|
||||
// }
|
||||
}
|
||||
SurfaceView renderView = null;
|
||||
rtcEngine.setupRemoteVideo(new VideoCanvas(null, Constants.RENDER_MODE_FIT, uid));
|
||||
@@ -603,7 +705,7 @@ public class AgoraManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void joinChannelEx(String token, String channelId, int uid) {
|
||||
public void joinChannelEx(String token, String channelId, int uid,String pkUserIds) {
|
||||
if (rtcEngine == null) {
|
||||
init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
}
|
||||
@@ -615,10 +717,12 @@ public class AgoraManager {
|
||||
options.autoSubscribeAudio = true;
|
||||
connection = new RtcConnection();
|
||||
connection.channelId = channelId;
|
||||
connection.localUid = uid;
|
||||
connection.localUid = SpUtil.getUserId();
|
||||
pkRoomId = channelId;
|
||||
rtcEngine.joinChannelEx(token, connection, options, getDefaultEventHandler());
|
||||
|
||||
pkUserId = Integer.parseInt(pkUserIds);
|
||||
// rtcEngine.joinChannelEx(token, connection, options, getDefaultEventHandler());
|
||||
// muteAllRemoteAudioStreamsEx(true);
|
||||
// muteAllRemoteAudioStreamsExUserId(false);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -628,7 +732,7 @@ public class AgoraManager {
|
||||
RtcConnection connection = new RtcConnection();
|
||||
connection.channelId = mRoomId;
|
||||
connection.localUid = uid;
|
||||
rtcEngine.leaveChannelEx(connection);
|
||||
// rtcEngine.leaveChannelEx(connection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,6 +740,16 @@ public class AgoraManager {
|
||||
|
||||
if (rtcEngine != null) {
|
||||
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
|
||||
// options.autoSubscribeVideo = true;
|
||||
// options.autoSubscribeAudio = true;
|
||||
//// 不发布摄像头采集的视频
|
||||
// options.publishCameraTrack = false;
|
||||
//// 不发布麦克风采集的视频
|
||||
// options.publishMicrophoneTrack = false;
|
||||
//// 在频道中发布屏幕采集的视频
|
||||
// options.publishScreenCaptureVideo = true;
|
||||
//// 在频道中发布屏幕采集的音频
|
||||
// options.publishScreenCaptureAudio = true;
|
||||
rtcEngine.setScreenCaptureScenario(Constants.ScreenScenarioType.SCREEN_SCENARIO_VIDEO);
|
||||
rtcEngine.updateChannelMediaOptions(options);
|
||||
}
|
||||
@@ -643,7 +757,30 @@ public class AgoraManager {
|
||||
|
||||
public void post() {
|
||||
if (rtcEngine != null) {
|
||||
// rtcEngine.setParameters("{\"che.video.mobile_1080p\":true}");
|
||||
// rtcEngine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);
|
||||
//
|
||||
// /*Enable video module*/
|
||||
// rtcEngine.enableVideo();
|
||||
// // Setup video encoding configs
|
||||
// rtcEngine.setVideoEncoderConfiguration(new VideoEncoderConfiguration(
|
||||
// VD_640x360,
|
||||
// FRAME_RATE_FPS_15,
|
||||
// STANDARD_BITRATE,
|
||||
// ORIENTATION_MODE_ADAPTIVE
|
||||
// ));
|
||||
// /*Set up to play remote sound with receiver*/
|
||||
// rtcEngine.setDefaultAudioRoutetoSpeakerphone(true);
|
||||
|
||||
ScreenCaptureParameters screenCaptureParameters = new ScreenCaptureParameters();
|
||||
// screenCaptureParameters.captureVideo = true;
|
||||
// screenCaptureParameters.videoCaptureParameters.width = 1440;
|
||||
// screenCaptureParameters.videoCaptureParameters.height = 1940;
|
||||
// screenCaptureParameters.videoCaptureParameters.framerate = 15;
|
||||
// screenCaptureParameters.captureAudio = true;
|
||||
// screenCaptureParameters.audioCaptureParameters.captureSignalVolume = 50;
|
||||
//// screenCaptureParameters.videoCaptureParameters.bitrate = 500;
|
||||
// rtcEngine.startScreenCapture(screenCaptureParameters);
|
||||
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = manager.getDefaultDisplay();
|
||||
|
||||
@@ -670,6 +807,26 @@ public class AgoraManager {
|
||||
}
|
||||
|
||||
|
||||
public void setExternalMediaProjection(MediaProjection[] mediaProjection){
|
||||
rtcEngine.setExternalMediaProjection(mediaProjection[0]);
|
||||
}
|
||||
|
||||
public void isPost(){
|
||||
if (rtcEngine != null){
|
||||
ScreenCaptureParameters screenCaptureParameters = new ScreenCaptureParameters();
|
||||
|
||||
// 设置新的屏幕共享参数
|
||||
screenCaptureParameters.captureVideo = true;
|
||||
screenCaptureParameters.videoCaptureParameters.width = 1280;
|
||||
screenCaptureParameters.videoCaptureParameters.height = 720;
|
||||
screenCaptureParameters.videoCaptureParameters.framerate = 30;
|
||||
|
||||
// 更新屏幕共享参数
|
||||
rtcEngine.updateScreenCaptureParameters(screenCaptureParameters);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void isMute(int index) {
|
||||
if (rtcEngine != null) {
|
||||
}
|
||||
@@ -681,6 +838,13 @@ public class AgoraManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void stopMusicPlayer() {
|
||||
if (musicPlayer != null) {
|
||||
musicPlayer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 完全销毁实例(只在应用退出时调用)
|
||||
*/
|
||||
@@ -727,17 +891,25 @@ public class AgoraManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//关闭对方的所有推流
|
||||
public void muteAllRemoteAudioStreamsEx(boolean enabled) {
|
||||
if (rtcEngine == null) {
|
||||
init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
}
|
||||
if (rtcEngine != null) {
|
||||
// RtcConnection connection = new RtcConnection();
|
||||
// connection.channelId = mRoomId;
|
||||
if (connection == null) {
|
||||
connection = new RtcConnection();
|
||||
connection.channelId = pkRoomId;
|
||||
}
|
||||
rtcEngine.muteAllRemoteAudioStreamsEx(enabled, connection);
|
||||
// rtcEngine.muteAllRemoteAudioStreamsEx(enabled, connection);
|
||||
}
|
||||
}
|
||||
//打开对方支持的推流
|
||||
public void muteAllRemoteAudioStreamsExUserId(boolean enabled){
|
||||
if (rtcEngine != null){
|
||||
// rtcEngine.muteRemoteAudioStreamEx(pkUserId,enabled,connection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,14 +927,13 @@ public class AgoraManager {
|
||||
* 启用或者关闭远端音频流
|
||||
*
|
||||
* @param enabled
|
||||
* @param uid
|
||||
*/
|
||||
public void muteLocalAudioStreamEx(boolean enabled, int uid) {
|
||||
public void muteLocalAudioStreamEx(boolean enabled) {
|
||||
if (rtcEngine == null) {
|
||||
init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
}
|
||||
// 正确做法
|
||||
rtcEngine.muteLocalAudioStreamEx(enabled, connection);
|
||||
// rtcEngine.muteLocalAudioStreamEx(enabled, connection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -796,6 +967,23 @@ public class AgoraManager {
|
||||
return isLocalAudioEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加事件监听器(用于全局回调)
|
||||
*/
|
||||
// public void addEventHandler(IRtcEngineEventHandler handler) {
|
||||
// if (handler != null && !eventHandlers.contains(handler)) {
|
||||
// eventHandlers.add(handler);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 移除事件监听器
|
||||
*/
|
||||
// public void removeEventHandler(IRtcEngineEventHandler handler) {
|
||||
// if (handler != null) {
|
||||
// eventHandlers.remove(handler);
|
||||
// }
|
||||
// }
|
||||
public void addSoundLevelListener(SoundLevelUpdateListener listener) {
|
||||
if (soundLevelUpdateListeners != null) {
|
||||
soundLevelUpdateListeners.add(listener);
|
||||
@@ -1114,19 +1302,25 @@ public class AgoraManager {
|
||||
|
||||
public static void stopMuisc() {
|
||||
if (musicPlayer != null) {
|
||||
// if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYING) {
|
||||
musicPlayer.stop();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseMusic() {
|
||||
if (musicPlayer != null) {
|
||||
// if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYING) {
|
||||
musicPlayer.pause();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public void resumeMusic() {
|
||||
if (musicPlayer != null) {
|
||||
// if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYING) {
|
||||
musicPlayer.resume();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1268,6 +1462,7 @@ public class AgoraManager {
|
||||
@Override
|
||||
public void retry(@NonNull DownloadTask task, @NonNull ResumeFailedCause cause) {
|
||||
com.xscm.moduleutil.utils.logger.Logger.e("retry", cause);
|
||||
// CrashReport.postCatchedException(new RuntimeException("下载文件重试:" + cause == null ? "" : cause.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1287,11 +1482,18 @@ public class AgoraManager {
|
||||
MusicFileBean musicFileBean = new MusicFileBean();
|
||||
musicFileBean.setFileData(convertFileToByteArray(task.getFile()));
|
||||
EventBus.getDefault().post(musicFileBean);
|
||||
if (cause != null && cause != EndCause.COMPLETED) {
|
||||
// CrashReport.postCatchedException(new RuntimeException("下载任务结束:" + cause == null ? "" : cause.name() + "_realCause:" + realCause == null ? "" : realCause.getMessage()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void setmSongCode(long songCode) {
|
||||
mSongCode = songCode;
|
||||
}
|
||||
|
||||
public void loadLrc(long songCode) {
|
||||
mSongCode = songCode;
|
||||
if (musicContentCenter != null) {
|
||||
|
||||
@@ -0,0 +1,362 @@
|
||||
package com.xscm.moduleutil.rtc;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ThreadUtils;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.event.ColoseCardEvent;
|
||||
import com.xscm.moduleutil.event.SurfaceEvent;
|
||||
import com.xscm.moduleutil.interfaces.SoundLevelUpdateListener;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import io.agora.musiccontentcenter.IAgoraMusicContentCenter;
|
||||
import io.agora.musiccontentcenter.IAgoraMusicPlayer;
|
||||
import io.agora.musiccontentcenter.Music;
|
||||
import io.agora.musiccontentcenter.MusicContentCenterConfiguration;
|
||||
import io.agora.rtc2.ChannelMediaOptions;
|
||||
import io.agora.rtc2.Constants;
|
||||
import io.agora.rtc2.IRtcEngineEventHandler;
|
||||
import io.agora.rtc2.RtcConnection;
|
||||
import io.agora.rtc2.RtcEngineEx;
|
||||
import io.agora.rtc2.video.VideoCanvas;
|
||||
|
||||
/**
|
||||
* com.xscm.moduleutil.rtc
|
||||
* qx
|
||||
* 2025/10/29
|
||||
*/
|
||||
public class AgoraManagerEx {
|
||||
|
||||
private static volatile AgoraManagerEx instance;
|
||||
private static RtcEngineEx rtcEngineEx;
|
||||
// private RtcEngineEx rtcEngineEx;
|
||||
private static Context context;
|
||||
private boolean isLocalAudioEnabled = true; // 默认开启麦克风
|
||||
// private final List<IRtcEngineEventHandler> eventHandlers = new ArrayList<>();
|
||||
private static IAgoraMusicContentCenter musicContentCenter;
|
||||
private static IAgoraMusicPlayer musicPlayer;
|
||||
private static MusicContentCenterConfiguration contentCenterConfiguration;
|
||||
private static String mRoomId = "";
|
||||
private static long mSongCode;
|
||||
|
||||
private static List<Music> musicList;
|
||||
private static boolean isBjMusic = false;
|
||||
private static List<SoundLevelUpdateListener> soundLevelUpdateListeners = new CopyOnWriteArrayList<>();
|
||||
private static ChannelMediaOptions options;
|
||||
private static RtcConnection connection;
|
||||
private String pkRoomId = "";
|
||||
private static String lastRoomId;
|
||||
|
||||
public int pkUserId;
|
||||
|
||||
public int getPkUserId() {
|
||||
return pkUserId;
|
||||
}
|
||||
|
||||
public void setPkUserId(int pkUserId) {
|
||||
this.pkUserId = pkUserId;
|
||||
}
|
||||
private static boolean isOnJoin = false;
|
||||
public void setLastRoomId(String value) {
|
||||
lastRoomId = value;
|
||||
}
|
||||
|
||||
public String getLastRoomId() {
|
||||
LogUtils.e("上次的房间id:" + lastRoomId);
|
||||
return lastRoomId;
|
||||
}
|
||||
|
||||
private AgoraManagerEx() {
|
||||
|
||||
}
|
||||
|
||||
public static AgoraManagerEx getInstance(Context con) {
|
||||
if (instance == null) {
|
||||
synchronized (AgoraManagerEx.class) {
|
||||
if (instance == null) {
|
||||
instance = new AgoraManagerEx();
|
||||
context = con.getApplicationContext(); // 使用ApplicationContext避免内存泄漏
|
||||
}
|
||||
}
|
||||
}
|
||||
// 确保引擎已初始化
|
||||
if (rtcEngineEx == null) {
|
||||
synchronized (AgoraManagerEx.class) {
|
||||
if (rtcEngineEx == null) {
|
||||
init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void init(String appId) {
|
||||
if (rtcEngineEx != null) {
|
||||
return;
|
||||
};
|
||||
|
||||
synchronized (AgoraManager.class) {
|
||||
if (rtcEngineEx != null) {
|
||||
return;
|
||||
}
|
||||
rtcEngineEx =AgoraManager.getInstance( context).rtcEngine;
|
||||
|
||||
// try {
|
||||
// RtcEngineConfig config = new RtcEngineConfig();
|
||||
// config.mContext = context;
|
||||
// config.mAppId = appId;
|
||||
// config.mEventHandler = getDefaultEventHandler();
|
||||
// config.mChannelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING;
|
||||
// config.mAudioScenario = Constants.AUDIO_SCENARIO_CHORUS;
|
||||
// config.mAreaCode = 1;
|
||||
//
|
||||
// rtcEngineEx = (RtcEngineEx) RtcEngineEx.create(config);
|
||||
// } catch (Exception e) {
|
||||
// Log.e("AgoraManager", "Failed to create RtcEngine", e);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (rtcEngineEx != null) {
|
||||
// try {
|
||||
// rtcEngineEx.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO,
|
||||
// Constants.AUDIO_SCENARIO_GAME_STREAMING);
|
||||
// rtcEngineEx.enableAudioVolumeIndication(200, 3, true);
|
||||
// rtcEngineEx.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);
|
||||
// rtcEngineEx.muteLocalAudioStream(true); // 默认静音
|
||||
// rtcEngineEx.muteAllRemoteAudioStreams(false); // 监听远端的音频
|
||||
//
|
||||
// // 设置参数时添加异常处理
|
||||
// try {
|
||||
// rtcEngineEx.setParameters("{\"che.audio.custom_payload_type\":73}");
|
||||
// rtcEngineEx.setParameters("{\"che.audio.custom_bitrate\":128000}");
|
||||
// rtcEngineEx.setParameters("{\"rtc.enable_nasa2\": true}");
|
||||
// rtcEngineEx.setParameters("{\"rtc.use_audio4\": true}");
|
||||
// rtcEngineEx.setParameters("{" +
|
||||
// "\"rtc.report_app_scenario\":" +
|
||||
// "{" +
|
||||
// "\"appScenario\":" + 100 + "," +
|
||||
// "\"serviceType\":" + 11 + "," +
|
||||
// "\"appVersion\":\"" + rtcEngineEx.getSdkVersion() + "\"" +
|
||||
// "}" +
|
||||
// "}");
|
||||
// rtcEngineEx.setParameters("{\"che.video.mobile_1080p\":true}");
|
||||
// } catch (Exception e) {
|
||||
// Log.w("AgoraManager", "Failed to set parameters", e);
|
||||
// }
|
||||
// /*Enable video module*/
|
||||
// rtcEngineEx.enableVideo();
|
||||
// /*Set up to play remote sound with receiver*/
|
||||
// rtcEngineEx.setDefaultAudioRoutetoSpeakerphone(true);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// Log.e("AgoraManager", "Failed to configure rtcEngineEx", e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private static IRtcEngineEventHandler getDefaultEventHandler() {
|
||||
return new IRtcEngineEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onRemoteAudioStateChanged(int uid, int state, int reason, int elapsed) {
|
||||
super.onRemoteAudioStateChanged(uid, state, reason, elapsed);
|
||||
LogUtils.e("onRemoteAudioStateChanged", "uid------>" + uid, "state------>" + state, "reason------>" + reason, "elapsed------>" + elapsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserMuteAudio(int uid, boolean muted) {
|
||||
super.onUserMuteAudio(uid, muted);
|
||||
LogUtils.e("onUserMuteAudio", "uid------>" + uid, "muted------>" + muted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
|
||||
LogUtils.e("onJoinChannelSuccess", "channel------>" + channel, "uid------>" + uid, "elapsed------>" + elapsed);
|
||||
if (!isOnJoin) {
|
||||
AgoraIsOPen isOPen = new AgoraIsOPen();
|
||||
isOPen.setOpen(true);
|
||||
EventBus.getDefault().post(isOPen);
|
||||
isOnJoin = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserJoined(int uid, int elapsed) {//远端用户加入频道
|
||||
|
||||
for (SoundLevelUpdateListener listener : soundLevelUpdateListeners) {
|
||||
if (listener != null) {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
// 远程用户音量变化
|
||||
listener.userJoined(uid, elapsed);
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserOffline(int uid, int reason) {//远端用户离开频道
|
||||
for (SoundLevelUpdateListener listener : soundLevelUpdateListeners) {
|
||||
if (listener != null) {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
// 远程用户音量变化
|
||||
listener.userOffline(uid, reason);
|
||||
// }
|
||||
});
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAudioVolumeIndication(AudioVolumeInfo[] speakers, int totalVolume) {
|
||||
super.onAudioVolumeIndication(speakers, totalVolume);
|
||||
|
||||
if (speakers == null || speakers.length == 0) return;
|
||||
|
||||
for (final AudioVolumeInfo info : speakers) {
|
||||
final int uid = info.uid;
|
||||
final int volume = info.volume;
|
||||
|
||||
// 回调所有监听器
|
||||
for (SoundLevelUpdateListener listener : soundLevelUpdateListeners) {
|
||||
if (listener != null) {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
// 远程用户音量变化
|
||||
listener.onRemoteSoundLevelUpdate(uid > 0 ? String.valueOf(uid) : SpUtil.getUserId() + "", volume);
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocalVideoStateChanged(Constants.VideoSourceType source, int state, int reason) {
|
||||
super.onLocalVideoStateChanged(source, state, reason);
|
||||
if (state == Constants.LOCAL_VIDEO_STREAM_STATE_CAPTURING && source.getValue() == Constants.VIDEO_SOURCE_SCREEN_PRIMARY) {
|
||||
options.publishScreenCaptureAudio = true;
|
||||
options.publishScreenCaptureVideo = true;
|
||||
options.publishCameraTrack = false;
|
||||
rtcEngineEx.updateChannelMediaOptions(options);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstRemoteAudioFrame(int uid, int elapsed) {
|
||||
super.onFirstRemoteAudioFrame(uid, elapsed);
|
||||
Log.i("RoomCabinFragment", "onFirstRemoteAudioFrame: uid->" + uid);
|
||||
|
||||
|
||||
}
|
||||
// 可继续扩展其他回调...
|
||||
|
||||
|
||||
@Override
|
||||
public void onFirstRemoteVideoFrame(int uid, int width, int height, int elapsed) {
|
||||
super.onFirstRemoteVideoFrame(uid, width, height, elapsed);
|
||||
SurfaceView renderView = new SurfaceView(context);
|
||||
SurfaceEvent surfaceEvent = new SurfaceEvent();
|
||||
surfaceEvent.setSurfaceView(renderView);
|
||||
surfaceEvent.setType(2);
|
||||
rtcEngineEx.setupRemoteVideo(new VideoCanvas(renderView, Constants.RENDER_MODE_FIT, uid));
|
||||
EventBus.getDefault().post(surfaceEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteVideoStateChanged(int uid, int state, int reason, int elapsed) {
|
||||
super.onRemoteVideoStateChanged(uid, state, reason, elapsed);
|
||||
Log.i("RoomCabinFragment", "onRemoteVideoStateChanged:uid->" + uid + ", state->" + state);
|
||||
if (state == Constants.REMOTE_AUDIO_STATE_STOPPED) {
|
||||
ColoseCardEvent renderView = new ColoseCardEvent();
|
||||
EventBus.getDefault().post(renderView);
|
||||
} else if (state == Constants.REMOTE_AUDIO_STATE_STARTING) {
|
||||
|
||||
SurfaceView renderView = new SurfaceView(context);
|
||||
rtcEngineEx.setupRemoteVideo(new VideoCanvas(renderView, Constants.RENDER_MODE_FIT, uid));
|
||||
SurfaceEvent surfaceEvent = new SurfaceEvent();
|
||||
surfaceEvent.setSurfaceView(renderView);
|
||||
surfaceEvent.setType(2);
|
||||
EventBus.getDefault().post(surfaceEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int err) {
|
||||
super.onError(err);
|
||||
}
|
||||
};
|
||||
}
|
||||
public void joinChannelEx(String token, String channelId, String pkUserIds) {
|
||||
// if (rtcEngineEx == null) {
|
||||
// init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
// }00602f7339ec98947deaeab173599891932IAAe1VwQOurJj57ZCxEJ3SO8VCK6MPKfAjdo5v/oOHPd5BTK+bCVBxwwIgDobHEAn5cDaQQAAQCflwNpAwCflwNpAgCflwNpBACflwNp
|
||||
if (rtcEngineEx != null) {
|
||||
options = new ChannelMediaOptions();
|
||||
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
|
||||
options.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING;
|
||||
options.publishMicrophoneTrack = true; // 是否发布麦克风音频
|
||||
options.enableAudioRecordingOrPlayout = true;
|
||||
options.autoSubscribeAudio = true;
|
||||
connection = new RtcConnection();
|
||||
connection.channelId = channelId;
|
||||
connection.localUid = SpUtil.getUserId();
|
||||
pkRoomId = channelId;
|
||||
pkUserId = Integer.parseInt(pkUserIds);
|
||||
rtcEngineEx.joinChannelEx(token, connection, options, getDefaultEventHandler());
|
||||
muteAllRemoteAudioStreamsEx(true);
|
||||
muteAllRemoteAudioStreamsExUserId(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void muteAllRemoteAudioStreamsEx(boolean enabled) {
|
||||
if (rtcEngineEx == null) {
|
||||
init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
}
|
||||
if (rtcEngineEx != null) {
|
||||
// RtcConnection connection = new RtcConnection();
|
||||
// connection.channelId = mRoomId;
|
||||
// if (connection == null) {
|
||||
// connection = new RtcConnection();
|
||||
// connection.channelId = pkRoomId;
|
||||
// }
|
||||
rtcEngineEx.muteAllRemoteAudioStreamsEx(enabled, connection);
|
||||
}
|
||||
}
|
||||
|
||||
public void muteLocalAudioStreamEx(boolean enabled) {
|
||||
if (rtcEngineEx == null) {
|
||||
init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId());
|
||||
}
|
||||
// 正确做法
|
||||
rtcEngineEx.muteLocalAudioStreamEx(enabled, connection);
|
||||
}
|
||||
|
||||
public void muteAllRemoteAudioStreamsExUserId(boolean enabled){
|
||||
if (rtcEngineEx != null){
|
||||
rtcEngineEx.muteRemoteAudioStreamEx(pkUserId,enabled,connection);
|
||||
}
|
||||
}
|
||||
|
||||
public void leaveChannelEx(String mRoomId, int uid) {
|
||||
if (rtcEngineEx != null) {
|
||||
RtcConnection connection = new RtcConnection();
|
||||
connection.channelId = mRoomId;
|
||||
connection.localUid = uid;
|
||||
rtcEngineEx.leaveChannelEx(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public enum EnvironmentEnum {
|
||||
"tcp://81.70.45.221",
|
||||
"https://vespa.qxyushen.top/h5"),
|
||||
TEST(//测试环境
|
||||
"http://tmd.xscmmidi.site/",
|
||||
"https://test.vespa.qxyushen.top/",
|
||||
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",
|
||||
"https://oss-cn-beijing.aliyuncs.com/",
|
||||
"LTAI5tKgrfcFQxH46ZwWYgFW",
|
||||
@@ -24,7 +24,7 @@ public enum EnvironmentEnum {
|
||||
"midi01",
|
||||
"https://midi01.oss-cn-beijing.aliyuncs.com/",
|
||||
"wxc7681513be9f926b",
|
||||
1600106397,
|
||||
1600096890,
|
||||
"02f7339ec98947deaeab173599891932",
|
||||
"tcp://1.13.181.248",
|
||||
"https://tmd.xscmmidi.site/h5");
|
||||
|
||||
@@ -133,8 +133,28 @@ public class RoomDefaultWheatView extends BaseWheatView {
|
||||
}
|
||||
|
||||
// setCardiac(pitBean.getPit_number(), 0.0f);
|
||||
}
|
||||
|
||||
updatePkState(bean);
|
||||
}
|
||||
private void updatePkState(RoomPitBean bean) {
|
||||
if (bean.is_pk()) {
|
||||
String userId = bean.getUser_id();
|
||||
if (userId != null && !userId.equals("0") && !userId.isEmpty()) {
|
||||
tv_time_pk.setVisibility(VISIBLE);
|
||||
setSex(bean.getCharm(), false);
|
||||
mCharmView.setVisibility(GONE);
|
||||
} else {
|
||||
tv_time_pk.setVisibility(GONE);
|
||||
}
|
||||
} else {
|
||||
tv_time_pk.setVisibility(GONE);
|
||||
if (isOn()) {
|
||||
mCharmView.setVisibility(VISIBLE);
|
||||
}else {
|
||||
mCharmView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setSex(String value, boolean format) {
|
||||
if (format) {
|
||||
tv_time_pk.setText(value);
|
||||
@@ -153,6 +173,10 @@ public class RoomDefaultWheatView extends BaseWheatView {
|
||||
}
|
||||
}
|
||||
|
||||
public void setTv_time_pk(boolean show){
|
||||
tv_time_pk.setVisibility(show?VISIBLE:GONE);
|
||||
}
|
||||
|
||||
private boolean showSexIcon = false;
|
||||
private String sex;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.widget.LinearLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomPitBean;
|
||||
|
||||
@@ -170,6 +171,9 @@ public class WheatLayoutManager {
|
||||
|
||||
private void addWheatViewItem(LinearLayout row, int pitNumber, int itemWidth, int layoutType) {
|
||||
RoomDefaultWheatView wheatView = createWheatView(pitNumber);
|
||||
if (layoutType==2){
|
||||
wheatView.setTv_time_pk(false);
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams params;
|
||||
if (pitNumber == 9 || pitNumber == 10) {
|
||||
@@ -226,25 +230,65 @@ public class WheatLayoutManager {
|
||||
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
||||
return metrics.widthPixels;
|
||||
}
|
||||
public void setUpData(RoomMessageEvent event,int layoutType){
|
||||
String fromPit=event.getText().getFrom_pit_number()!=null?event.getText().getFrom_pit_number():"";
|
||||
String toPitNumber=event.getText().getTo_pit_number()!=null?event.getText().getTo_pit_number():"";
|
||||
if (fromPit.equals("") || toPitNumber.equals("")){
|
||||
return;
|
||||
}
|
||||
RoomDefaultWheatView fromWheatView = findWheatViewByPitNumber(Integer.parseInt(fromPit));
|
||||
RoomDefaultWheatView toWheatView = findWheatViewByPitNumber(Integer.parseInt(toPitNumber));
|
||||
RoomPitBean fromPitBean=fromWheatView.pitBean;
|
||||
RoomPitBean toPitBean=toWheatView.pitBean;
|
||||
String tmpNumber=fromPitBean.getPit_number();
|
||||
fromPitBean.setPit_number(toPitBean.getPit_number());
|
||||
toPitBean.setPit_number(tmpNumber);
|
||||
|
||||
|
||||
public void updateSingleWheat(RoomPitBean pitBean, int pitNumber) {
|
||||
toWheatView.setData(fromPitBean);
|
||||
fromWheatView.setData(toPitBean);
|
||||
|
||||
if (layoutType==2){
|
||||
fromWheatView.setTv_time_pk(false);
|
||||
toWheatView.setTv_time_pk(false);
|
||||
}else if (layoutType==1){
|
||||
fromWheatView.setTv_time_pk(true);
|
||||
toWheatView.setTv_time_pk(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSingleWheat(RoomPitBean pitBean, int pitNumber,int layoutType) {
|
||||
if (pitList == null || pitList.isEmpty() || pitNumber < 1 || pitNumber > 10) return;
|
||||
if (isSingleMode && this.currentSinglePit != pitNumber) return;
|
||||
|
||||
RoomDefaultWheatView wheatView = findWheatViewByPitNumber(pitNumber);
|
||||
if (wheatView != null) {
|
||||
pitBean.set_pk(true);
|
||||
wheatView.setData(pitBean);
|
||||
if (layoutType==2){
|
||||
wheatView.setTv_time_pk(false);
|
||||
}else if (layoutType==1){
|
||||
wheatView.setTv_time_pk(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSingleCharm(RoomPitBean pitBean, int pitNumber) {
|
||||
public void updateSingleCharm(RoomPitBean pitBean, int pitNumber,int layoutType) {
|
||||
if (pitList == null || pitList.isEmpty() || pitNumber < 1 || pitNumber > 10) return;
|
||||
if (isSingleMode && this.currentSinglePit != pitNumber) return;
|
||||
|
||||
RoomDefaultWheatView wheatView = findWheatViewByPitNumber(pitNumber);
|
||||
if (wheatView != null) {
|
||||
wheatView.setCharm(pitBean.getCharm());
|
||||
RoomPitBean bean=wheatView.pitBean;
|
||||
bean=pitBean ;
|
||||
|
||||
if (layoutType==2){
|
||||
wheatView.setTv_time_pk(false);
|
||||
}else if (layoutType==1){
|
||||
wheatView.setTv_time_pk(true);
|
||||
}
|
||||
wheatView.setSex(bean.getCharm(),true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +320,7 @@ public class WheatLayoutManager {
|
||||
public void refreshWheatData(List<RoomPitBean> newPitList, List<Integer> changedPits) {
|
||||
this.pitList = newPitList;
|
||||
for (int pitNumber : changedPits) {
|
||||
updateSingleWheat(pitList.get(pitNumber - 1), pitNumber);
|
||||
updateSingleWheat(pitList.get(pitNumber - 1), pitNumber,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,18 +43,18 @@
|
||||
app:loopCount="0"
|
||||
app:source="ripple3695.svga" />
|
||||
|
||||
<!-- <com.xscm.moduleutil.widget.AvatarFrameView-->
|
||||
<!-- android:id="@+id/iv_ripple"-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
<!-- android:layout_height="0dp"-->
|
||||
<!-- android:layout_marginTop="@dimen/dp_8"-->
|
||||
<!-- app:autoPlay="false"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintDimensionRatio="1:1.05"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="parent"-->
|
||||
<!-- />-->
|
||||
<!-- <com.xscm.moduleutil.widget.AvatarFrameView-->
|
||||
<!-- android:id="@+id/iv_ripple"-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
<!-- android:layout_height="0dp"-->
|
||||
<!-- android:layout_marginTop="@dimen/dp_8"-->
|
||||
<!-- app:autoPlay="false"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintDimensionRatio="1:1.05"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="parent"-->
|
||||
<!-- />-->
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_sex"
|
||||
@@ -135,16 +135,16 @@
|
||||
android:id="@+id/iv_frame"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="@dimen/dp_12"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginEnd="@dimen/dp_12"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHeight_percent="0.98"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.98" />
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_riv_bottom"
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintHeight_default="percent"
|
||||
app:layout_constraintHeight_percent="0.52" />
|
||||
app:layout_constraintHeight_percent="0.5" />
|
||||
|
||||
<com.xscm.moduleutil.widget.AvatarFrameView
|
||||
android:id="@+id/iv_frame"
|
||||
@@ -75,7 +75,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintHeight_default="percent"
|
||||
app:layout_constraintHeight_percent="0.5"
|
||||
app:layout_constraintHeight_percent="0.52"
|
||||
app:loopCount="0"
|
||||
app:source="ripple3695.svga" />
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ import com.xscm.modulemain.dialog.RoomMessageDialogFragment
|
||||
import com.xscm.modulemain.dialog.RoomOnlineDialogFragment
|
||||
import com.xscm.modulemain.dialog.RoomPkDialogFragment
|
||||
import com.xscm.modulemain.dialog.RoomSettingFragment
|
||||
import com.xscm.modulemain.dialog.RoomUserInfoFragment
|
||||
import com.xscm.modulemain.dialog.SoundEffectsDialogFragment
|
||||
import com.xscm.modulemain.dialog.TourClubDialogFragment
|
||||
import com.xscm.modulemain.manager.RoomManager
|
||||
@@ -142,6 +143,7 @@ import com.xscm.moduleutil.interfaces.OnMusicItemClickListener
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton.OnMessageReceivedListener
|
||||
import com.xscm.moduleutil.rtc.AgoraManager
|
||||
import com.xscm.moduleutil.rtc.AgoraManagerEx
|
||||
import com.xscm.moduleutil.rtc.MusicPlayBean
|
||||
import com.xscm.moduleutil.service.MyRoomSingleton
|
||||
import com.xscm.moduleutil.utils.ARouteConstants
|
||||
@@ -154,6 +156,7 @@ import com.xscm.moduleutil.utils.roomview.GiftDisplayManager
|
||||
import com.xscm.moduleutil.widget.CircularProgressView
|
||||
import com.xscm.moduleutil.widget.CustomMusicFloatingView
|
||||
import com.xscm.moduleutil.widget.QXGiftPlayerManager
|
||||
import com.xscm.moduleutil.widget.RoomKtvWheatView
|
||||
import com.xscm.moduleutil.widget.SilentCountDownTimer
|
||||
import com.xscm.moduleutil.widget.ViewUtils
|
||||
import com.xscm.moduleutil.widget.ViewUtils.OnViewCreatedListener
|
||||
@@ -599,7 +602,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
this.mRoomBean = roomBean
|
||||
this.mRoomUserBean = resp.user_info
|
||||
this.mRoomOwnerBean = resp.room_owner
|
||||
this.mPitList = mRoomBean!!.pit_list
|
||||
this.mPitList = mRoomBean?.pit_list ?: ArrayList()
|
||||
this.roomId = roomBean.room_id
|
||||
MessageListenerSingleton.getInstance().joinGroup(roomId) //加入房间im
|
||||
ImageUtils.loadHeadCC(resp.room_info.room_cover, mBinding!!.roomTop.avatar)
|
||||
@@ -618,16 +621,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
number = roomBean.online_number
|
||||
mBinding!!.roomTop.tvNum.text = number.toString() + ""
|
||||
|
||||
val userIds = StringBuilder()
|
||||
for (i in mRoomInfoResp!!.room_info.pit_list.indices) {
|
||||
val userId = mRoomInfoResp!!.room_info.pit_list[i].user_id
|
||||
if (userId != null && userId != "0" && !userId.isEmpty()) {
|
||||
if (userIds.length > 0) {
|
||||
userIds.append(",")
|
||||
}
|
||||
userIds.append(userId)
|
||||
}
|
||||
}
|
||||
setviewyc(true)
|
||||
// 确保Fragment已完全初始化后再调用getUpRoomInfo
|
||||
if (publicScreenFragment != null && publicScreenFragment!!.isAdded && publicScreenFragment!!.view != null) {
|
||||
publicScreenFragment!!.getUpRoomInfo(resp)
|
||||
@@ -639,7 +633,18 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
Log.e("Fragment", "Fragment transaction skipped due to state loss.")
|
||||
}
|
||||
LogUtils.e("加入", roomId)
|
||||
|
||||
val userIds = StringBuilder()
|
||||
if (mRoomInfoResp?.room_info?.pit_list != null) {
|
||||
for (i in mRoomInfoResp?.room_info?.pit_list!!.indices) {
|
||||
val userId = mRoomInfoResp!!.room_info.pit_list[i].user_id
|
||||
if (userId != null && userId != "0" && !userId.isEmpty()) {
|
||||
if (userIds.length > 0) {
|
||||
userIds.append(",")
|
||||
}
|
||||
userIds.append(userId)
|
||||
}
|
||||
}
|
||||
}
|
||||
CommonAppContext.getInstance().isPlaying = true
|
||||
CommonAppContext.getInstance().playId = roomId
|
||||
CommonAppContext.getInstance().playName = mRoomBean!!.room_name
|
||||
@@ -1194,7 +1199,11 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
view
|
||||
)
|
||||
}
|
||||
|
||||
mBinding!!.roomTop.muZc.setOnClickListener { view: View ->
|
||||
this.onClick(
|
||||
view
|
||||
)
|
||||
}
|
||||
mBinding!!.inputMenu1.performClick()
|
||||
|
||||
V2TIMManager.getConversationManager()
|
||||
@@ -1300,7 +1309,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
} else if (msgType == 1001) {
|
||||
handleMsgType1001()
|
||||
} else if (msgType == 1002) {
|
||||
handleMsgType1002()
|
||||
handleMsgType1002(messageEvent, text)
|
||||
} else if (msgType == 1029) {
|
||||
handleMsgType1029(messageEvent, text)
|
||||
} else if (msgType == 1021) {
|
||||
@@ -1329,7 +1338,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
setRoleType(3, -11)
|
||||
}
|
||||
} else if (msgType == 125) {
|
||||
handleMsgType125(messageEvent, text)
|
||||
handleMsgType125(messageEvent, text.text)
|
||||
} else if (msgType == 1006) {
|
||||
handleMsgType1006()
|
||||
} else if (msgType == 1007) {
|
||||
@@ -1744,13 +1753,13 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
for (roomPitBean in mRoomInfoResp!!.song_pit_list) {
|
||||
AgoraManager.getInstance(this@RoomActivity).ClientRole(false)
|
||||
ivWheatFeeding(com.xscm.moduleutil.R.mipmap.room_wheat_feeding)
|
||||
mBinding!!.rlMic.visibility = View.GONE
|
||||
mBinding?.rlMic?.visibility = View.GONE
|
||||
}
|
||||
if (mRoomInfoResp!!.song_user_info != null && mRoomInfoResp!!.song_user_info.user_id != null) {
|
||||
if (mRoomInfoResp!!.song_user_info.user_id == SpUtil.getUserId().toString() + "") {
|
||||
AgoraManager.getInstance(this@RoomActivity).ClientRole(false)
|
||||
ivWheatFeeding(com.xscm.moduleutil.R.mipmap.room_wheat_feeding)
|
||||
mBinding!!.rlMic.visibility = View.GONE
|
||||
mBinding?.rlMic?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1993,6 +2002,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
if (text.fromUserInfo.user_id == SpUtil.getUserId()) {
|
||||
LogUtils.e("退出房间")
|
||||
MvpPre!!.quitRoom(roomId, SpUtil.getUserId().toString() + "")
|
||||
MessageListenerSingleton.quitGroup(roomId);
|
||||
quit();
|
||||
performExitRoom(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2001,12 +2013,18 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
mBinding!!.roomTop.tvNum.text = number.toString() + ""
|
||||
}
|
||||
|
||||
private fun handleMsgType1002() {
|
||||
private fun handleMsgType1002(messageEvent: RoomMessageEvent, text: T?) {
|
||||
number--
|
||||
if (number < 0) {
|
||||
number = 0
|
||||
}
|
||||
mBinding!!.roomTop.tvNum.text = number.toString() + ""
|
||||
if (text == null || text.fromUserInfo == null) return
|
||||
if (text.fromUserInfo.user_id == SpUtil.getUserId()) {
|
||||
MessageListenerSingleton.quitGroup(roomId);
|
||||
quit();
|
||||
performExitRoom(1);
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleMsgType1029(messageEvent: RoomMessageEvent, text: T?) {
|
||||
@@ -2204,23 +2222,19 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
return mRoomInfoResp
|
||||
}
|
||||
|
||||
private fun handleMsgType125(messageEvent: RoomMessageEvent, text: T?) {
|
||||
private fun handleMsgType125(messageEvent: RoomMessageEvent, text: String) {
|
||||
if (text == null) return
|
||||
|
||||
try {
|
||||
val parsedText = GsonUtils.fromJson<text>(
|
||||
text.text,
|
||||
text::class.java
|
||||
)
|
||||
val parsedText: RoomMessageEvent.text = GsonUtils.fromJson(text, RoomMessageEvent.text::class.java)
|
||||
if (parsedText.is_mute == 1) {
|
||||
AgoraManager.getInstance(this).ClientRole(false)
|
||||
AgoraManager.getInstance(this).muteLocalAudioStreamEx(false, SpUtil.getUserId())
|
||||
AgoraManagerEx.getInstance(this).muteLocalAudioStreamEx(true)
|
||||
} else {
|
||||
AgoraManager.getInstance(this).ClientRole(true)
|
||||
AgoraManager.getInstance(this).muteLocalAudioStreamEx(true, SpUtil.getUserId())
|
||||
AgoraManagerEx.getInstance(this).muteLocalAudioStreamEx(false)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
// Handle exception
|
||||
LogUtils.e("handleMsgType125: " + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2536,8 +2550,57 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
aBoolean = true
|
||||
}
|
||||
}
|
||||
} else if (id == R.id.mu_zc) {
|
||||
val muZc: RoomKtvWheatView = mBinding!!.roomTop.muZc
|
||||
if (muZc.getUserId() != "") {
|
||||
RoomUserInfoFragment.show(
|
||||
roomId,
|
||||
muZc.getUserId(),
|
||||
muZc.pitNumber,
|
||||
getHostUser(),
|
||||
false,
|
||||
2,
|
||||
isNumberWhether(),
|
||||
supportFragmentManager
|
||||
)
|
||||
} else {
|
||||
MvpPre!!.applyPit(roomId, "9")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isNumberWhether(): Int {
|
||||
if (mRoomInfoResp!!.getUser_info().getPit_number() == 9) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
private fun getHostUser(): Int {
|
||||
if (mRoomInfoResp?.getUser_info()?.getPit_number() == 9) {
|
||||
return if (mRoomInfoResp?.getUser_info()?.getIs_room_owner() == 1) {
|
||||
1
|
||||
} else if (mRoomInfoResp?.getUser_info()?.getIs_management() == 1) {
|
||||
2
|
||||
} else if (mRoomInfoResp?.getUser_info()?.getIs_host() == 1) {
|
||||
3
|
||||
} else {
|
||||
4
|
||||
}
|
||||
} else {
|
||||
if (mRoomInfoResp?.getUser_info()?.getIs_room_owner() == 1) {
|
||||
return 1
|
||||
}
|
||||
if (mRoomInfoResp?.getUser_info()?.getIs_management() == 1) {
|
||||
return 2
|
||||
}
|
||||
if (mRoomInfoResp?.getUser_info()?.getIs_host() == 1) {
|
||||
return 3
|
||||
}
|
||||
return 4
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: 2025/9/18 type==1:退出房间,进入到首页 2:退出当前页,不导航到首页,是从首页点击关闭悬浮退出的
|
||||
fun performExitRoom(type: Int) {
|
||||
@@ -2597,13 +2660,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
appStateListener!!.isAppInBackground = true
|
||||
}
|
||||
QXGiftPlayerManager.getInstance(applicationContext).destroyEffectSvga()
|
||||
|
||||
val am = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
val tasks = am.appTasks // 获取当前应用的任务栈
|
||||
tasks.forEach { task ->
|
||||
Log.d("TaskStack", "任务栈ID:${task.taskInfo.id} currId:${this.getTaskId()},包含的Activity:${task.taskInfo.baseActivity?.className}")
|
||||
}
|
||||
|
||||
if (ActivityUtils.getActivityList().size <= 1){
|
||||
singleTaskToActivity(MainActivity::class.java)
|
||||
}else{
|
||||
@@ -2723,12 +2779,12 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
fun setrlMic(voive: Boolean) {
|
||||
mBinding!!.rlMic.visibility =
|
||||
mBinding?.rlMic?.visibility =
|
||||
if (voive) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
fun rlMore(voive: Boolean) {
|
||||
mBinding!!.rlMore.visibility = if (voive) View.GONE else View.GONE
|
||||
mBinding!!.rlMore.visibility = if (voive) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
fun ivMic(inIvMic: Int) {
|
||||
@@ -2736,16 +2792,15 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
fun setRoleType(roleType: Int, pit_number: Int) {
|
||||
val rl_voice = mBinding!!.rlVoive // 注意:原拼写错误已修正
|
||||
val rl_mic = mBinding!!.rlMic
|
||||
val rl_more = mBinding!!.rlMore
|
||||
val rl_misc = mBinding!!.rlMisc
|
||||
val rl_voice = mBinding?.rlVoive // 注意:原拼写错误已修正 喇叭
|
||||
val rl_mic = mBinding?.rlMic//麦克风
|
||||
val rl_more = mBinding?.rlMore //PK
|
||||
val rl_misc = mBinding?.rlMisc //音乐
|
||||
|
||||
// 默认隐藏所有按钮
|
||||
rl_voice.visibility = View.GONE
|
||||
rl_more.visibility = View.GONE
|
||||
rl_misc.visibility = View.GONE
|
||||
rl_mic.visibility = View.GONE
|
||||
rl_voice?.visibility = View.GONE
|
||||
rl_more?.visibility = View.GONE
|
||||
rl_misc?.visibility = View.GONE
|
||||
rl_mic?.visibility = View.GONE
|
||||
|
||||
// 空指针保护
|
||||
if (mRoomInfoResp == null || mRoomInfoResp!!.room_info == null || mRoomInfoResp!!.user_info == null) {
|
||||
@@ -2758,70 +2813,80 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
// 特殊房间类型处理(优先级最高)
|
||||
if ("6" == typeId) {
|
||||
mBinding!!.rlMessage.visibility = View.GONE
|
||||
mBinding?.rlMessage?.visibility = View.GONE
|
||||
return // 全部隐藏,无需继续处理
|
||||
} else {
|
||||
mBinding?.rlMessage?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
|
||||
// 根据角色类型显示按钮
|
||||
when (roleType) {
|
||||
1, 2, 3 -> {
|
||||
rl_voice.visibility = View.VISIBLE
|
||||
rl_mic.visibility =
|
||||
rl_voice?.visibility = View.VISIBLE
|
||||
rl_mic?.visibility =
|
||||
if (pit_number != 0) View.VISIBLE else View.GONE
|
||||
rl_more.visibility =
|
||||
if (pit_number == 9) View.GONE else View.GONE
|
||||
rl_misc.visibility = View.VISIBLE
|
||||
rl_more?.visibility =
|
||||
if (pit_number == 9) View.VISIBLE else View.GONE
|
||||
rl_misc?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
0 -> {
|
||||
rl_voice.visibility = View.VISIBLE
|
||||
rl_mic.visibility =
|
||||
rl_voice?.visibility = View.VISIBLE
|
||||
rl_mic?.visibility =
|
||||
if (pit_number != 0) View.VISIBLE else View.GONE
|
||||
rl_misc.visibility = View.VISIBLE
|
||||
rl_misc?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
5 -> {
|
||||
rl_voice.visibility = View.VISIBLE
|
||||
rl_more.visibility = View.GONE
|
||||
rl_misc.visibility = View.VISIBLE
|
||||
rl_voice?.visibility = View.VISIBLE
|
||||
rl_more?.visibility = View.GONE
|
||||
rl_misc?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
if (roleType != 5) {
|
||||
rl_misc.visibility = View.VISIBLE
|
||||
rl_misc?.visibility = View.VISIBLE
|
||||
if (userPitNumber == 9) {
|
||||
rl_more.visibility = View.GONE
|
||||
rl_more?.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// label_id 和 type_id 联合判断
|
||||
if (mutableListOf<String>("1", "3", "4", "8").contains(typeId) && "2" == labelId) {
|
||||
rl_more.visibility = View.GONE
|
||||
if (mutableListOf<String>("1").contains(typeId) && "1" == labelId) {
|
||||
rl_more?.visibility = View.VISIBLE
|
||||
rl_misc?.visibility = View.VISIBLE
|
||||
}else{
|
||||
rl_more?.visibility = View.GONE
|
||||
rl_misc?.visibility = View.GONE
|
||||
}
|
||||
|
||||
// mic 显示逻辑
|
||||
if (userPitNumber > 0) {
|
||||
rl_mic.visibility = View.VISIBLE
|
||||
switchMic(2)
|
||||
} else {
|
||||
if (pit_number == 888) {
|
||||
rl_mic.visibility = View.VISIBLE
|
||||
switchMic(2)
|
||||
} else if (pit_number == -1) {
|
||||
rl_mic.visibility = View.VISIBLE // 原代码此处缺少 View. 前缀,已补全
|
||||
rl_mic?.visibility = View.VISIBLE
|
||||
if (CommonAppContext.getInstance().isMai) {
|
||||
switchMic(1)
|
||||
} else {
|
||||
rl_mic.visibility = View.GONE
|
||||
switchMic(2)
|
||||
}
|
||||
} else {
|
||||
if (pit_number == 888) {
|
||||
rl_mic?.visibility = View.VISIBLE
|
||||
switchMic(2)
|
||||
} else if (pit_number == -1) {
|
||||
rl_mic?.visibility = View.VISIBLE // 原代码此处缺少 View. 前缀,已补全
|
||||
switchMic(1)
|
||||
} else {
|
||||
rl_mic?.visibility = View.GONE
|
||||
switchMic(2)
|
||||
}
|
||||
}
|
||||
|
||||
if ("7" == typeId || "2" == typeId) {
|
||||
rl_more.visibility = View.GONE
|
||||
rl_misc.visibility = View.GONE
|
||||
rl_more?.visibility = View.GONE
|
||||
rl_misc?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2995,7 +3060,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
// TODO: 2025/8/26 加入房间
|
||||
override fun roomInfo(resp: RoomInfoResp) {
|
||||
AppStateManager.getInstance().roomInfo = resp
|
||||
this.mRoomInfoResp = resp
|
||||
val roomBean = resp.room_info
|
||||
this.mRoomBean = roomBean
|
||||
this.mRoomUserBean = resp.user_info
|
||||
@@ -3478,7 +3542,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
xlhDjs(xlhBean.end_time)
|
||||
} else if (xlhBean.from_type == 104) {
|
||||
|
||||
mBinding?.xlhRk?.visibility = View.GONE
|
||||
releaseCountDownTimer1()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.PkSwTokenBean;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
|
||||
@@ -22,6 +23,8 @@ public class SingSongContacts {
|
||||
void endPk();
|
||||
|
||||
void userOnlineStatus(List<UserOnlineStatusBean> list);
|
||||
|
||||
void postAgora(PkSwTokenBean pkSwTokenBean);
|
||||
}
|
||||
|
||||
public interface IEmotionRoomPre extends IPresenter {
|
||||
|
||||
@@ -60,15 +60,18 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
implements ChatRoomContacts.View {
|
||||
|
||||
private final static String TAG = "聊天室";
|
||||
|
||||
private boolean isBottom = true;
|
||||
private int count = 0;
|
||||
|
||||
private String toChatUsername;
|
||||
|
||||
private RoomInfoResp roomInfoResp;
|
||||
private EaseChatAdapter easeChatAdapter;
|
||||
private CountDownTimer countDownTimer;
|
||||
private String roomId;
|
||||
private MessageListenerSingleton.PublicScreenMessageListener messageListener;
|
||||
|
||||
// 清屏
|
||||
// 在需要的地方调用 Activity 的方法
|
||||
public void someMethod() {
|
||||
easeChatAdapter.clearData();
|
||||
}
|
||||
@@ -90,6 +93,7 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
roomId = arguments.getString("roomId");
|
||||
Logger.e(TAG, "toChatUsername:" + toChatUsername);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,10 +104,6 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}
|
||||
|
||||
public void onFragmentShowDestroy() {
|
||||
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
}
|
||||
if (messageListener != null) {
|
||||
LogUtils.e("移除监听器");
|
||||
MessageListenerSingleton.getInstance().removePublicScreenMessageListener(messageListener);
|
||||
@@ -115,6 +115,12 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
onChatRoomViewCreation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录聊天室
|
||||
*/
|
||||
@@ -136,7 +142,9 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
*/
|
||||
private void setupMessageListener() {
|
||||
// 创建并添加监听器
|
||||
messageListener = message -> {
|
||||
messageListener = new MessageListenerSingleton.PublicScreenMessageListener() {
|
||||
@Override
|
||||
public void onPublicScreenMessageReceived(RoomMessageEvent message) {
|
||||
// 确保在主线程更新 UI
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@@ -146,6 +154,7 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
MessageListenerSingleton.getInstance().addPublicScreenMessageListener(messageListener);
|
||||
}
|
||||
@@ -174,6 +183,7 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}, 300); // 延迟300ms确保监听器已注册
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initListener() {
|
||||
mBinding.recycleViewPublic.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@@ -213,6 +223,7 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
if (easeChatAdapter != null) {
|
||||
easeChatAdapter.clearData();
|
||||
}
|
||||
toChatUsername = roomInfoResp.getRoom_info().getChatrooms();
|
||||
this.roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
@@ -307,7 +318,10 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setUpPublicScreen() {
|
||||
//如果有数据或者recycle view有item view就删除;否则程序崩溃,找不到item
|
||||
if (mBinding.recycleViewPublic.getChildCount() > 0) {
|
||||
mBinding.recycleViewPublic.removeAllViews();
|
||||
}
|
||||
@@ -318,6 +332,8 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
isBottom = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_fragement_trans_ease_chat;
|
||||
@@ -326,6 +342,7 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
|
||||
public void onClick(View view) {
|
||||
int view_id = view.getId();
|
||||
|
||||
if (view_id == R.id.tv_tab_all) {
|
||||
easeChatAdapter.setShowType(EaseChatAdapter.SHOW_TYPE_ALL);
|
||||
mBinding.tvTabAll.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
@@ -368,6 +385,8 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
|
||||
}
|
||||
|
||||
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void fasong(RoomInputEvent roomInputEvent) {
|
||||
String message = roomInputEvent.text;
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
@@ -376,11 +395,11 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent(1, roomInfoResp.getRoom_info().getRoom_id(), t);
|
||||
handleRoomMessage(roomMessageEvent);
|
||||
String json = GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
// 创建自定义消息
|
||||
V2TIMMessage v2TIMMessage = V2TIMManager.getMessageManager().createCustomMessage(binaryData);
|
||||
// 发送消息
|
||||
// 发送消息
|
||||
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, null, "room" + roomInfoResp.getRoom_info().getRoom_id(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, false, null, new V2TIMSendCallback<V2TIMMessage>() {
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
@@ -399,9 +418,11 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void sendChatEmoji(EmotionDeatils emotionDeatils) {
|
||||
EmotionDeatils event = new EmotionDeatils();
|
||||
if (emotionDeatils != null && emotionDeatils.getChildren() != null && !emotionDeatils.getChildren().isEmpty() && !emotionDeatils.getChildren().isEmpty()) {
|
||||
if (emotionDeatils != null && emotionDeatils.getChildren() != null && !emotionDeatils.getChildren().isEmpty() && emotionDeatils.getChildren().size() > 0) {
|
||||
int position = new Random().nextInt(emotionDeatils.getChildren().size());
|
||||
Children children = emotionDeatils.getChildren().get(position);
|
||||
event.setImage(children.getImage());
|
||||
@@ -419,11 +440,11 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
roomMessageEvent.setText(t);
|
||||
handleRoomMessage(roomMessageEvent);
|
||||
String json = GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
// 创建自定义消息
|
||||
V2TIMMessage v2TIMMessage = V2TIMManager.getMessageManager().createCustomMessage(binaryData);
|
||||
// 发送消息
|
||||
// 发送消息
|
||||
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, null, "room" + roomId, V2TIMMessage.V2TIM_PRIORITY_NORMAL, false, null, new V2TIMSendCallback<V2TIMMessage>() {
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
@@ -455,7 +476,7 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
return;
|
||||
}
|
||||
|
||||
if (roomId == null || !message.getRoomId().contains(roomId)) {
|
||||
if (roomId == null ||(!message.getRoomId().contains(roomId)&&message.getMsgType()!=125)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -528,7 +549,6 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}
|
||||
postAndAddMessage(message);
|
||||
break;
|
||||
|
||||
case 123:
|
||||
easeChatAdapter.clearData();
|
||||
postAndAddMessage(message);
|
||||
@@ -556,6 +576,9 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
case 1061:
|
||||
case 1025:
|
||||
case 1058:
|
||||
case 125:
|
||||
|
||||
// EventBus.getDefault().post(message);
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
@@ -610,13 +633,10 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
break;
|
||||
|
||||
case 1049:
|
||||
// if (text != null && text.getStep() != 3) {
|
||||
postAndAddMessage(message);
|
||||
// }
|
||||
break;
|
||||
|
||||
case 1005:
|
||||
// EventBus.getDefault().post(message);
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
@@ -626,7 +646,6 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
break;
|
||||
|
||||
default:
|
||||
// EventBus.getDefault().post(message);
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
@@ -637,6 +656,9 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
private EMMessageInfo createMessageInfoIfNeeded(RoomMessageEvent message) {
|
||||
int msgType = message.getMsgType();
|
||||
RoomMessageEvent.T text = message.getText();
|
||||
if (text.getIs_pk()!=null&&text.getIs_pk().equals("1")){
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (msgType) {
|
||||
case 1001:
|
||||
@@ -668,6 +690,9 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}
|
||||
|
||||
private void addSingleMessage(RoomMessageEvent message) {
|
||||
if (message.getText().getIs_pk()!=null&&message.getText().getIs_pk().equals("1")){
|
||||
return;
|
||||
}
|
||||
if (easeChatAdapter != null) {
|
||||
if (message.getMsgType() == 1049) {
|
||||
if (message.getText().getStep() != 3) {
|
||||
@@ -682,30 +707,37 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}
|
||||
|
||||
private void postAndAddMessage(RoomMessageEvent message) {
|
||||
// EventBus.getDefault().post(message);
|
||||
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
addSingleMessage(message);
|
||||
}
|
||||
|
||||
|
||||
// 优化 scrollToBottomIfNeed 方法
|
||||
private void scrollToBottomIfNeed() {
|
||||
if (isBottom && easeChatAdapter != null) {
|
||||
if (isBottom && mBinding.recycleViewPublic != null && easeChatAdapter != null) {
|
||||
int itemCount = easeChatAdapter.getItemCount();
|
||||
if (itemCount > 0) {
|
||||
mBinding.recycleViewPublic.scrollToPosition(itemCount - 1);
|
||||
}
|
||||
} else {
|
||||
count++;
|
||||
if (mBinding.tvCount != null) {
|
||||
mBinding.tvCount.setText(count + "条新消息");
|
||||
mBinding.tvCount.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// 当未读消息过多时,限制数量显示
|
||||
if (count > 99) {
|
||||
if (mBinding.tvCount != null) {
|
||||
mBinding.tvCount.setText("99+条新消息");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@@ -715,6 +747,8 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 房间信息
|
||||
*
|
||||
@@ -725,4 +759,12 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
this.roomInfoResp = resp;
|
||||
}
|
||||
|
||||
private void refreshSelectLast() {
|
||||
if (mBinding.recycleViewPublic != null) {
|
||||
mBinding.recycleViewPublic.scrollToPosition(easeChatAdapter.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ public class FriendshipRoomFragment extends BaseRoomFragment<FriendshipRoomPrese
|
||||
int screenWidth = displayMetrics.widthPixels;
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
|
||||
int popupWidth = (int) (screenWidth * 0.35); // 屏幕宽度的 60%
|
||||
int popupWidth = (int) (screenWidth * 0.25); // 屏幕宽度的 60%
|
||||
int popupHeight = (int) (screenHeight * 0.13); // 屏幕高度的 40%
|
||||
|
||||
|
||||
|
||||
@@ -4,12 +4,18 @@ import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.TimeUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
@@ -32,6 +38,7 @@ import com.xscm.moduleutil.event.CabinEvent;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.widget.dialog.CommonDialog;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
@@ -54,8 +61,10 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
private static final String LABEL_ID_MOVIE = "5";
|
||||
protected String roomId;
|
||||
protected String pitNumber;//当前点击的麦序
|
||||
protected CommonDialog commonDialog;
|
||||
CountDownTimer mCountDownTimer;
|
||||
private RoomInfoResp roomInfoResp;
|
||||
private int remainingTime;
|
||||
private boolean isShow = false;
|
||||
private RoomCpUserBean cpUserBean;
|
||||
private boolean isMicPlace = false;
|
||||
@@ -79,11 +88,23 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
// roomInfoResp = (RoomInfoResp) arguments.getSerializable("roomInfoResp");
|
||||
// if (roomInfoResp != null) {
|
||||
// roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
// cpUserBean = roomInfoResp.getCp_user();
|
||||
// label_id = roomInfoResp.getRoom_info().getLabel_id();
|
||||
// }
|
||||
}
|
||||
private boolean isLandscape;
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
// if (getActivity() instanceof RoomActivity) {
|
||||
// ((RoomActivity) getActivity()).changeBackground(com.xscm.moduleutil.R.mipmap.cabin_bj);
|
||||
// ((RoomActivity) getActivity()).setvisibTop(false);
|
||||
// }
|
||||
|
||||
if (CommonAppContext.getInstance().lable_id.equals("6") && CommonAppContext.getInstance().isMicPlace){
|
||||
joinChannel();
|
||||
isMicPlace = true;
|
||||
@@ -92,6 +113,29 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
}
|
||||
}
|
||||
|
||||
private void enableNotifications() {
|
||||
if (NotificationManagerCompat.from(requireContext()).areNotificationsEnabled()) {
|
||||
Log.d("RoomCabinFragment", "Notifications enable!");
|
||||
return;
|
||||
}
|
||||
Log.d("RoomCabinFragment", "Notifications not enable!");
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle("提示")
|
||||
.setMessage("请打开通知权限,防止后台共享屏幕中断")
|
||||
.setPositiveButton("设置", (dialog, which) -> {
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getActivity().getPackageName());
|
||||
intent.putExtra(Settings.EXTRA_CHANNEL_ID, getActivity().getApplicationInfo().uid);
|
||||
} else {
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
}
|
||||
startActivity(intent);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoomCabinPresenter bindPresenter() {
|
||||
@@ -101,6 +145,76 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (roomInfoResp == null) return;
|
||||
|
||||
if (roomInfoResp != null) {
|
||||
roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
cpUserBean = roomInfoResp.getCp_user();
|
||||
label_id = roomInfoResp.getRoom_info().getLabel_id();
|
||||
}
|
||||
if (roomInfoResp != null && roomInfoResp.getRoom_owner().getUser_id().equals(SpUtil.getUserId()+"")){
|
||||
mBinding.im3.setVisibility(VISIBLE);
|
||||
// setvkk(false);
|
||||
}else {
|
||||
mBinding.im3.setVisibility(GONE);
|
||||
}
|
||||
|
||||
mBinding.ivExit.setOnClickListener(this::onHeartLineClicked);
|
||||
|
||||
// 获取当前用户 ID
|
||||
String currentUserId = SpUtil.getUserId() + "";
|
||||
|
||||
// 定义两个 RoomPitBean 对象,分别用于显示在 roomMakeWheat1 和 roomMakeWheat2
|
||||
RoomPitBean selfBean = new RoomPitBean(); // 自己的 bean
|
||||
RoomPitBean otherBean = new RoomPitBean(); // 另一个用户的 bean
|
||||
|
||||
boolean isSelfFirst = false;
|
||||
|
||||
// 判断当前用户是 user_id 还是 user_id1
|
||||
if (cpUserBean != null) {
|
||||
if (currentUserId.equals(cpUserBean.getUser_id())) {
|
||||
// 当前用户是 user_id
|
||||
selfBean.setUser_id(cpUserBean.getUser_id());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code());
|
||||
selfBean.setNickname(cpUserBean.getNickname());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar());
|
||||
selfBean.setDress(cpUserBean.getDress());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id1());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code1());
|
||||
otherBean.setNickname(cpUserBean.getNickname1());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar1());
|
||||
otherBean.setDress(cpUserBean.getDress1());
|
||||
otherBean.setPit_number("000");
|
||||
|
||||
|
||||
} else if (currentUserId.equals(cpUserBean.getUser_id1())) {
|
||||
// 当前用户是 user_id1,则交换位置
|
||||
selfBean.setUser_id(cpUserBean.getUser_id1());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code1());
|
||||
selfBean.setNickname(cpUserBean.getNickname1());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar1());
|
||||
selfBean.setDress(cpUserBean.getDress1());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code());
|
||||
otherBean.setNickname(cpUserBean.getNickname());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar());
|
||||
otherBean.setDress(cpUserBean.getDress());
|
||||
otherBean.setPit_number("000");
|
||||
}
|
||||
}
|
||||
// 不论谁是自己,始终将自己放在 roomMakeWheat1
|
||||
mBinding.roomMakeWheat1.setData(selfBean);
|
||||
// 将另一个用户的数据放在 roomMakeWheat2
|
||||
mBinding.roomMakeWheat2.setData(otherBean);
|
||||
mBinding.tvMainTitle.setText(roomInfoResp.getRoom_info().getRoom_name());
|
||||
mBinding.tvHeartValue2.setText(roomInfoResp.getRoom_info().getHot_value());
|
||||
if (cpUserBean != null) {
|
||||
countDownTime(Long.parseLong(cpUserBean.getTime_day()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +222,9 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
|
||||
mBinding.im1.setOnClickListener(v -> {
|
||||
mBinding.im1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!isShow) {
|
||||
switchMic(2);
|
||||
isMute(1);
|
||||
@@ -116,8 +232,11 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
switchMic(1);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mBinding.im2.setOnClickListener(v -> {
|
||||
mBinding.im2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomPitBean roomPitBean = mBinding.roomMakeWheat2.pitBean;
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setUser_id(Integer.parseInt(roomPitBean.getUser_id()!=null ? roomPitBean.getUser_id() : "0"));
|
||||
@@ -126,6 +245,7 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
userInfo.setPit_number("");
|
||||
RoomGiftDialogFragment.show(null, userInfo, roomInfoResp.getRoom_info().getRoom_id(),0,"", getParentFragmentManager());
|
||||
|
||||
}
|
||||
});
|
||||
if (!CommonAppContext.getInstance().isShowAg){
|
||||
switchMic(2);
|
||||
@@ -134,7 +254,11 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
switchMic(2);
|
||||
}
|
||||
|
||||
mBinding.im3.setOnClickListener(v -> {
|
||||
mBinding.im3.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// requestScreenCapture();
|
||||
if (!isMicPlace) {
|
||||
joinChannel();
|
||||
isMicPlace = true;
|
||||
@@ -147,17 +271,45 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
mBinding.im3.setImageResource(com.xscm.moduleutil.R.mipmap.gongxiang);
|
||||
CommonAppContext.getInstance().isMicPlace = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (roomInfoResp != null && roomInfoResp.getRoom_owner().getUser_id().equals(SpUtil.getUserId()+"")){
|
||||
mBinding.im3.setVisibility(VISIBLE);
|
||||
// setvkk(false);
|
||||
}else {
|
||||
mBinding.im3.setVisibility(GONE);
|
||||
}
|
||||
|
||||
// if (label_id!=null&& label_id.equals(LABEL_ID_MOVIE)){
|
||||
// mBinding.im3.setVisibility(GONE);
|
||||
// }
|
||||
}
|
||||
// 获取 MediaProjectionManager
|
||||
// MediaProjectionManager mediaProjectionManager = (MediaProjectionManager) getSelfActivity().getSystemService(Context.MEDIA_PROJECTION_SERVICE);
|
||||
// private MediaProjection[] mediaProjection = new MediaProjection[1];
|
||||
// private final ActivityResultLauncher<Intent> mediaProjectionLauncher = registerForActivityResult(
|
||||
// new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
// if (result.getResultCode() == Activity.RESULT_OK) {
|
||||
// try {
|
||||
// // 获取申请到的 MediaProjection
|
||||
// mediaProjection[0] = mediaProjectionManager
|
||||
// .getMediaProjection(result.getResultCode(), result.getData());
|
||||
// // r MediaProjection,需要在 startScreenCapture 之前调用
|
||||
//
|
||||
// AgoraManager.getInstance(getActivity()).setExternalMediaProjection(mediaProjection);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
|
||||
|
||||
// 请求屏幕捕获
|
||||
private void requestScreenCapture() {
|
||||
// Intent intent = mediaProjectionManager.createScreenCaptureIntent();
|
||||
// mediaProjectionLauncher.launch(intent);
|
||||
}
|
||||
public void handleMsgType1028(RoomMessageEvent messageEvent){
|
||||
if (messageEvent.getMsgType()==1028){
|
||||
mBinding.tvHeartValue2.setText(messageEvent.getText().getHot_value());
|
||||
@@ -165,13 +317,85 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
}
|
||||
public void upRoomInfo(RoomInfoResp roomInfoResp){
|
||||
this.roomInfoResp = roomInfoResp;
|
||||
|
||||
// if (roomInfoResp != null) {
|
||||
// roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
// cpUserBean = roomInfoResp.getCp_user();
|
||||
// label_id = roomInfoResp.getRoom_info().getLabel_id();
|
||||
// }
|
||||
// if (roomInfoResp != null && roomInfoResp.getRoom_owner().getUser_id().equals(SpUtil.getUserId()+"")){
|
||||
// mBinding.im3.setVisibility(VISIBLE);
|
||||
//// setvkk(false);
|
||||
// }else {
|
||||
// mBinding.im3.setVisibility(GONE);
|
||||
// }
|
||||
//
|
||||
// mBinding.ivExit.setOnClickListener(this::onHeartLineClicked);
|
||||
//
|
||||
// // 获取当前用户 ID
|
||||
// String currentUserId = SpUtil.getUserId() + "";
|
||||
//
|
||||
//// 定义两个 RoomPitBean 对象,分别用于显示在 roomMakeWheat1 和 roomMakeWheat2
|
||||
// RoomPitBean selfBean = new RoomPitBean(); // 自己的 bean
|
||||
// RoomPitBean otherBean = new RoomPitBean(); // 另一个用户的 bean
|
||||
//
|
||||
// boolean isSelfFirst = false;
|
||||
//
|
||||
//// 判断当前用户是 user_id 还是 user_id1
|
||||
// if (cpUserBean != null) {
|
||||
// if (currentUserId.equals(cpUserBean.getUser_id())) {
|
||||
// // 当前用户是 user_id
|
||||
// selfBean.setUser_id(cpUserBean.getUser_id());
|
||||
// selfBean.setUser_code(cpUserBean.getUser_code());
|
||||
// selfBean.setNickname(cpUserBean.getNickname());
|
||||
// selfBean.setAvatar(cpUserBean.getAvatar());
|
||||
// selfBean.setDress(cpUserBean.getDress());
|
||||
// selfBean.setPit_number("000");
|
||||
//
|
||||
// otherBean.setUser_id(cpUserBean.getUser_id1());
|
||||
// otherBean.setUser_code(cpUserBean.getUser_code1());
|
||||
// otherBean.setNickname(cpUserBean.getNickname1());
|
||||
// otherBean.setAvatar(cpUserBean.getAvatar1());
|
||||
// otherBean.setDress(cpUserBean.getDress1());
|
||||
// otherBean.setPit_number("000");
|
||||
//
|
||||
//
|
||||
// } else if (currentUserId.equals(cpUserBean.getUser_id1())) {
|
||||
// // 当前用户是 user_id1,则交换位置
|
||||
// selfBean.setUser_id(cpUserBean.getUser_id1());
|
||||
// selfBean.setUser_code(cpUserBean.getUser_code1());
|
||||
// selfBean.setNickname(cpUserBean.getNickname1());
|
||||
// selfBean.setAvatar(cpUserBean.getAvatar1());
|
||||
// selfBean.setDress(cpUserBean.getDress1());
|
||||
// selfBean.setPit_number("000");
|
||||
//
|
||||
// otherBean.setUser_id(cpUserBean.getUser_id());
|
||||
// otherBean.setUser_code(cpUserBean.getUser_code());
|
||||
// otherBean.setNickname(cpUserBean.getNickname());
|
||||
// otherBean.setAvatar(cpUserBean.getAvatar());
|
||||
// otherBean.setDress(cpUserBean.getDress());
|
||||
// otherBean.setPit_number("000");
|
||||
// }
|
||||
// }
|
||||
//// 不论谁是自己,始终将自己放在 roomMakeWheat1
|
||||
// mBinding.roomMakeWheat1.setData(selfBean);
|
||||
//// 将另一个用户的数据放在 roomMakeWheat2
|
||||
// mBinding.roomMakeWheat2.setData(otherBean);
|
||||
// mBinding.tvMainTitle.setText(roomInfoResp.getRoom_info().getRoom_name());
|
||||
// mBinding.tvHeartValue2.setText(roomInfoResp.getRoom_info().getHot_value());
|
||||
// if (cpUserBean != null) {
|
||||
// countDownTime(Long.parseLong(cpUserBean.getTime_day()));
|
||||
// }
|
||||
// mediaProjectionManager = (MediaProjectionManager) getContext().getSystemService(Context.MEDIA_PROJECTION_SERVICE);
|
||||
}
|
||||
|
||||
public void upCabinFragment(long time){
|
||||
countDownTime( time);
|
||||
}
|
||||
|
||||
|
||||
private boolean isFullscreen = false;
|
||||
|
||||
|
||||
public void switchMic(int type) {
|
||||
|
||||
if (type == 1) {
|
||||
@@ -211,14 +435,43 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
);
|
||||
}
|
||||
|
||||
public void roomInfoEvent(RoomMessageEvent messageEvent) {
|
||||
if (messageEvent.getMsgType() == 1028) {
|
||||
mBinding.tvHeartValue2.setText(messageEvent.getText().getHot_value());
|
||||
}
|
||||
}
|
||||
|
||||
private void onHeartLineClicked(View view) {
|
||||
if (view.getId() == R.id.iv_exit) {
|
||||
// EventBus.getDefault().post(new RoomOutEvent());
|
||||
// ARouter.getInstance().build(ARouteConstants.LIVE_ROOM).withString("form","首页热门列表").withString("roomId", item.getRoom_id()).navigation();
|
||||
ExitRoomBottomSheet bottomSheet = ExitRoomBottomSheet.newInstance(false,true,true);
|
||||
|
||||
bottomSheet.setOnOptionSelectedListener(new ExitRoomBottomSheet.OnOptionSelectedListener() {
|
||||
@Override
|
||||
public void onMinimize() {
|
||||
// 处理最小化逻辑,比如不销毁 Activity,仅移至后台
|
||||
// CommonAppContext.getInstance().isShow = false;
|
||||
// ARouter.getInstance().build(ARouteConstants.ME).navigation();//栈顶复用
|
||||
// if (getActivity() instanceof RoomActivity) {
|
||||
// ((RoomActivity) getActivity()).moveTaskToBack(true);
|
||||
// }
|
||||
|
||||
// 在Activity中
|
||||
// Intent serviceIntent = new Intent(getContext(), FloatingWindowService.class);
|
||||
|
||||
// 判断是否已有浮窗正在显示
|
||||
// if (!EasyFloat.isShow("testFloat")) {
|
||||
// // 启动前台服务以维持浮窗
|
||||
// Context context = requireContext();
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// // Android 12+ 需要指定 foregroundServiceType
|
||||
// Intent serviceIntent = new Intent(context, FloatingWindowService.class);
|
||||
// serviceIntent.setAction("ACTION_START_FLOAT");
|
||||
// context.startForegroundService(serviceIntent);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,6 +480,7 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
// 调用退出房间方法
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
MvpPre.quitRoom(roomId, SpUtil.getUserId() + "");
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance(getActivity()).getLastRoomId()).navigation();
|
||||
return;
|
||||
}
|
||||
if (roomInfoResp != null) {
|
||||
@@ -266,12 +520,15 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
int time1 = (int) (millisUntilFinished / 1000);
|
||||
// pitBean.setCount_down(time1);
|
||||
setTime(time1);
|
||||
remainingTime = time1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
setTime(0);
|
||||
remainingTime = 0;
|
||||
}
|
||||
};
|
||||
mCountDownTimer.start();
|
||||
@@ -332,6 +589,7 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_cabin_fragment;
|
||||
@@ -340,6 +598,8 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
@Override
|
||||
public void roomInfoUpdate(RoomInfoResp resp) {
|
||||
roomInfoResp = resp;
|
||||
// updateWheatData();
|
||||
|
||||
if (roomInfoResp != null) {
|
||||
roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
cpUserBean = roomInfoResp.getCp_user();
|
||||
@@ -361,6 +621,8 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
RoomPitBean selfBean = new RoomPitBean(); // 自己的 bean
|
||||
RoomPitBean otherBean = new RoomPitBean(); // 另一个用户的 bean
|
||||
|
||||
boolean isSelfFirst = false;
|
||||
|
||||
// 判断当前用户是 user_id 还是 user_id1
|
||||
if (cpUserBean != null) {
|
||||
if (currentUserId.equals(cpUserBean.getUser_id())) {
|
||||
@@ -406,6 +668,7 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
if (cpUserBean != null) {
|
||||
countDownTime(Long.parseLong(cpUserBean.getTime_day()));
|
||||
}
|
||||
// mediaProjectionManager = (MediaProjectionManager) getContext().getSystemService(Context.MEDIA_PROJECTION_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -438,11 +701,37 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
((RoomActivity) getActivity()).quitRoom2(roomId);
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
((RoomActivity) getActivity()).jiaR();
|
||||
//// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance(getActivity()).getLastRoomId()).navigation();
|
||||
return;
|
||||
}else {
|
||||
((RoomActivity) getActivity()).performExitRoom(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// private MediaProjection[] mediaProjection = new MediaProjection[1];
|
||||
// private MediaProjectionManager mediaProjectionManager;
|
||||
// private final ActivityResultLauncher<Intent> mediaProjectionLauncher = registerForActivityResult(
|
||||
// new ActivityResultContracts.StartActivityForResult(),
|
||||
// result -> {
|
||||
// if (result.getResultCode() == Activity.RESULT_OK) {
|
||||
// try {
|
||||
// mediaProjection[0] = mediaProjectionManager
|
||||
// .getMediaProjection(result.getResultCode(), result.getData());
|
||||
// joinChannel();
|
||||
// } catch (Exception e) {
|
||||
// Log.e("RoomCabinFragment", "error msg: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
|
||||
private void isConfig() {
|
||||
|
||||
enableNotifications();
|
||||
}
|
||||
|
||||
|
||||
private void joinChannel() {
|
||||
|
||||
AgoraManager.getInstance(getActivity()).updateChannelMediaOptions();
|
||||
@@ -578,5 +867,11 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
|
||||
public void releaseResources(){
|
||||
releaseCountDownTimer();
|
||||
// ImageUtils.clearDiskCache(getActivity());
|
||||
// if (mediaProjection[0] != null) {
|
||||
// mediaProjection[0].stop();
|
||||
// mediaProjection[0] = null;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,6 +353,10 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
||||
}
|
||||
|
||||
public void onFragmentShowDestroy() {
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
// ImageUtils.clearDiskCache(getActivity());
|
||||
// 释放SVGA动画资源
|
||||
if (mBinding != null && mBinding.svgaNobility != null) {
|
||||
mBinding.svgaNobility.release();
|
||||
@@ -428,12 +432,19 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
LogUtils.e("lxj", "创建room时间:" + TimeUtils.date2String(new Date()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
// 在 onStop 中也注销 EventBus,防止内存泄漏
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
// 提前释放计时器资源
|
||||
releaseCountDownTimer();
|
||||
@@ -645,7 +656,9 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
||||
String labelId = mRoomInfoResp.getRoom_info().getLabel_id();
|
||||
|
||||
Fragment newFragment = null;
|
||||
|
||||
// if (getActivity() instanceof RoomActivity) {
|
||||
// ((RoomActivity) getActivity()).setviewyc(true);
|
||||
// }
|
||||
if ("1".equals(typeId)) {
|
||||
if ("1".equals(labelId)) {
|
||||
singSongFragment = SingSongFragment.newInstance(mRoomInfoResp);
|
||||
|
||||
@@ -31,7 +31,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ObjectUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.activity.RoomActivity;
|
||||
import com.xscm.modulemain.databinding.FragmentSingSongBinding;
|
||||
@@ -46,6 +48,7 @@ import com.xscm.modulemain.activity.room.presenter.SingSongPresenter;
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
import com.xscm.moduleutil.base.BaseRoomFragment;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.PkSwTokenBean;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
@@ -60,6 +63,7 @@ import com.xscm.moduleutil.event.RoomWheatEvent;
|
||||
import com.xscm.moduleutil.event.UserInfoShowEvent;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.rtc.AgoraManagerEx;
|
||||
import com.xscm.moduleutil.utils.GsonUtils;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
@@ -80,6 +84,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@@ -97,10 +102,12 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
protected RoomInfoResp roomInfoRespPk;
|
||||
protected String pitNumber;//当前点击的麦序
|
||||
protected CommonDialog commonDialog;
|
||||
// private WheatLayoutManager wheatLayoutManager;
|
||||
private WheatLayoutSingManager wheatLayoutSingManager;
|
||||
private WheatLayoutManager wheatLayoutManager1;
|
||||
private WheatLayoutManager wheatLayoutManager2;
|
||||
|
||||
|
||||
private RoomPitBean roomPitBean;
|
||||
|
||||
private PopupWindow popupWindow;
|
||||
@@ -108,6 +115,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
CountDownTimer mCountDownTimersta;
|
||||
private RoomFragment parentFragment;
|
||||
List<RoomPitBean> pitList;
|
||||
private SharedViewModel sharedViewModel;
|
||||
|
||||
public static SingSongFragment newInstance(RoomInfoResp roomInfoResp) {
|
||||
Bundle args = new Bundle();
|
||||
@@ -124,6 +132,20 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
this.roomInfoResp = roomInfoResp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
// roomInfoResp = (RoomInfoResp) arguments.getSerializable("roomInfo");
|
||||
// roomId = roomInfoResp == null ? "" : roomInfoResp.getRoom_info().getRoom_id();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
mBinding.btSta.setOnClickListener(this);
|
||||
mBinding.btStop.setOnClickListener(this);
|
||||
mBinding.imMkf.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingSongPresenter bindPresenter() {
|
||||
@@ -132,16 +154,19 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
// Observable.timer(20, TimeUnit.MILLISECONDS)
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(aLong -> {
|
||||
// upDtaView(true);
|
||||
// });
|
||||
Observable.timer(10, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> {
|
||||
upDtaView(true);
|
||||
});
|
||||
Observable.timer(60, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> {
|
||||
upDtaView(false);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void upRoomInfo(RoomInfoResp roomInfoResp) {
|
||||
@@ -154,7 +179,16 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
((RoomActivity) getActivity()).setvisibTop(true);
|
||||
}
|
||||
// 初始化 PopupWindow
|
||||
createView(isFirst);
|
||||
if (roomInfoResp != null) {
|
||||
if (roomInfoResp.getPk_info() != null) {
|
||||
|
||||
upWheter();
|
||||
updateWheatData();
|
||||
} else {
|
||||
isWhether2(isFirst);
|
||||
}
|
||||
}
|
||||
|
||||
parentFragment = (RoomFragment) getParentFragment();
|
||||
|
||||
}
|
||||
@@ -162,7 +196,18 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
roomId = roomInfoResp.getRoom_info().getRoom_id(); initPopupWindow();
|
||||
// sharedViewModel = new ViewModelProvider(requireActivity()).get(SharedViewModel.class);
|
||||
//
|
||||
// // 观察专门给子Fragment的数据
|
||||
// sharedViewModel.getChildFragmentData().observe(getViewLifecycleOwner(), data -> {
|
||||
// if (data != null) {
|
||||
// // 处理数据
|
||||
// roomInfoUpdate(data);
|
||||
// }
|
||||
// });
|
||||
roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
initPopupWindow();
|
||||
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@@ -212,15 +257,20 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
View popupView = LayoutInflater.from(getContext()).inflate(R.layout.popup_menu, null, false);
|
||||
|
||||
// 创建 PopupWindow
|
||||
// popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
|
||||
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
// 设置固定宽高(单位是像素)
|
||||
int screenWidth = displayMetrics.widthPixels;
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
|
||||
int popupWidth = (int) (screenWidth * 0.35); // 屏幕宽度的 60%
|
||||
int popupWidth = (int) (screenWidth * 0.25); // 屏幕宽度的 60%
|
||||
int popupHeight = (int) (screenHeight * 0.13); // 屏幕高度的 40%
|
||||
|
||||
// 创建 PopupWindow,使用.WRAP_CONTENT实现自适应
|
||||
// popupWindow = new PopupWindow(popupView,
|
||||
// ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
// ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
// true);
|
||||
|
||||
|
||||
popupWindow = new PopupWindow(popupView, popupWidth, popupHeight, true);
|
||||
|
||||
@@ -238,19 +288,19 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
setPopupMenuClickListener(popupView, null);
|
||||
}
|
||||
|
||||
@SuppressLint("UseSwitchCompatOrMaterialCode")
|
||||
private void setPopupMenuClickListener(View popupView, View view) {
|
||||
|
||||
TextView tvHugMic = popupView.findViewById(R.id.tv_hug_mic);
|
||||
Switch switchCloseMic = popupView.findViewById(R.id.sw_close_mic);
|
||||
Switch switchLockMic = popupView.findViewById(R.id.sw_lock_mic);
|
||||
if (view != null) {
|
||||
switchCloseMic.setChecked(roomPitBean.getIs_mute() == 1);//是否禁麦
|
||||
switchLockMic.setChecked(roomPitBean.getIs_lock() == 1);//是否闭麦
|
||||
switchCloseMic.setChecked(roomPitBean.getIs_mute() == 1 ? true : false);//是否禁麦
|
||||
switchLockMic.setChecked(roomPitBean.getIs_lock() == 1 ? true : false);//是否闭麦
|
||||
}
|
||||
switchCloseMic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
// AgoraManager.getInstance(getContext()).enableHeadphoneMonitor(b);
|
||||
MvpPre.setMutePit(roomId, pitNumber + "", b ? "2" : "4");
|
||||
}
|
||||
});
|
||||
@@ -259,6 +309,9 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
switchLockMic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
// AgoraManager.getInstance(getContext()).enableHeadphoneMonitor(b);
|
||||
//耳返设置完保存本地
|
||||
// SpUtil.setAuricularBack(b ? 1 : 0);
|
||||
MvpPre.setLockPit(roomId, pitNumber + "", b ? "1" : "0");
|
||||
}
|
||||
});
|
||||
@@ -295,6 +348,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
return false;
|
||||
} else {
|
||||
if (roomInfoResp.getRoom_info().getPit_list().size() > 8) {
|
||||
// if (roomInfoResp.getRoom_info().getPit_list().get(8).getUser_id().equals(SpUtil.getUserId() + "") && !pitNumber.equals("10")) {
|
||||
if (roomInfoResp.getUser_info().getPit_number() == 9 && !pitNumber.equals("10")) {
|
||||
return true;
|
||||
}
|
||||
@@ -317,6 +371,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
|
||||
protected void tzblChanged() {
|
||||
// mBinding.dhv9.updateTzbl(SpUtil.getTzbl(roomId));
|
||||
|
||||
StringBuilder userIds = new StringBuilder();
|
||||
for (int i = 0; i < roomInfoResp.getRoom_info().getPit_list().size(); i++) {
|
||||
@@ -372,16 +427,11 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
return false; // 不是快速重复点击
|
||||
}
|
||||
|
||||
private void createView(boolean isFirst) {
|
||||
private void isWhether2(boolean isFirst) {
|
||||
mBinding.flexboxLayout.setVisibility(View.VISIBLE);
|
||||
mBinding.cl.setVisibility(View.GONE);
|
||||
|
||||
|
||||
mBinding.btSta.setOnClickListener(this);
|
||||
mBinding.btStop.setOnClickListener(this);
|
||||
mBinding.imMkf.setOnClickListener(this);
|
||||
|
||||
|
||||
FlexboxLayout flexboxLayout = mBinding.flexboxLayout;
|
||||
wheatLayoutSingManager = new WheatLayoutSingManager(CommonAppContext.getInstance(), flexboxLayout);
|
||||
if (!isFirst) {
|
||||
@@ -447,6 +497,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
} else {
|
||||
mBinding.flexboxLayout.setVisibility(View.GONE);
|
||||
mBinding.cl.setVisibility(View.VISIBLE);
|
||||
|
||||
MvpPre.postRoomInfo(roomInfoResp.getPk_info().getPk_room_id(), roomInfoResp.getUser_info().getPit_number() + "", 1);
|
||||
}
|
||||
if (roomInfoResp.getUser_info().getPit_number() != 9) {
|
||||
@@ -457,6 +508,92 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
tzblChanged();
|
||||
}
|
||||
|
||||
private void isWhether() {
|
||||
if (roomInfoResp == null) {
|
||||
mBinding.flexboxLayout.setVisibility(View.VISIBLE);
|
||||
mBinding.cl.setVisibility(View.GONE);
|
||||
FlexboxLayout flexboxLayout = mBinding.flexboxLayout;
|
||||
wheatLayoutSingManager = new WheatLayoutSingManager(requireContext(), flexboxLayout);
|
||||
wheatLayoutSingManager.setOnWheatClickListener(new WheatLayoutSingManager.OnWheatClickListener() {
|
||||
@Override
|
||||
public void onWheatClick(RoomSingSongWheatView view, int pitNumber1) {
|
||||
// RoomPitBean pitBean = roomInfoResp.getRoom_info().getPit_list().get(pitNumber1 - 1);
|
||||
RoomPitBean pitBean = view.pitBean;
|
||||
|
||||
// 可选:点击事件处理
|
||||
Log.d("Wheat", "Clicked pit: " + pitNumber1);
|
||||
if (!pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
RoomUserInfoFragment.show(roomId, pitBean.getUser_id(), pitBean.getPit_number() + "", getHostUser(), false, 3, isNumberWhether(), getChildFragmentManager());
|
||||
// 点击的麦位是当前麦位
|
||||
// 可以执行相应的操作,如显示提示信息或执行其他逻辑
|
||||
} else {
|
||||
// 点击的麦位不是当前麦位
|
||||
// 可以执行相应的操作,如显示提示信息或执行其他逻辑
|
||||
if (cheackWether(pitBean.getPit_number())) {
|
||||
|
||||
pitNumber = pitBean.getPit_number();
|
||||
roomPitBean = pitBean;
|
||||
showPopupMenu(view); // v 是点击的按钮视图
|
||||
} else if (pitNumber1 == 10 && isUserHostOfRoom()) {
|
||||
RoomOnlineDialogFragment.show(roomId, pitNumber1 + "", roomInfoResp.getUser_info(), roomInfoResp, getChildFragmentManager());
|
||||
} else if (pitNumber1 != 10) {
|
||||
MvpPre.applyPit(roomId, pitNumber1 + "");
|
||||
} else {
|
||||
ToastUtils.show("请等待主持抱麦");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMakeWheatClick(RoomSingSongWheatView view, int pitNumber) {
|
||||
ToastUtils.show("点击麦位");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeilingClick(RoomSingSongWheatView view, int pitNumber) {
|
||||
// ToastUtils.show("点击魅力值");
|
||||
RoomCharmDialog.newInstance(roomId, view.pitBean.getUser_id()).show(getChildFragmentManager(), "RoomCharmDialog");
|
||||
}
|
||||
});
|
||||
List<RoomPitBean> pitList = new ArrayList<>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
RoomPitBean pitBean = new RoomPitBean();
|
||||
pitBean.setPit_number("" + i);
|
||||
pitBean.setUser_id("0");
|
||||
pitBean.setCharm("");
|
||||
pitList.add(pitBean);
|
||||
}
|
||||
wheatLayoutSingManager.setWheatData(pitList, false);
|
||||
} else {
|
||||
// if (roomInfoResp.getPk_info() == null) {
|
||||
//
|
||||
//
|
||||
// if (!ObjectUtils.isEmpty(roomInfoResp.getRoom_info().getPit_list()) && roomInfoResp.getRoom_info().getPit_list().size() == 10) {
|
||||
// wheatLayoutSingManager.setWheatData(roomInfoResp.getRoom_info().getPit_list());
|
||||
// }
|
||||
//// initWheatLayout();
|
||||
// } else {
|
||||
// mBinding.flexboxLayout.setVisibility(View.GONE);
|
||||
// mBinding.cl.setVisibility(View.VISIBLE);
|
||||
// MvpPre.postRoomInfo(roomInfoResp.getPk_info().getPk_room_id(), roomInfoResp.getUser_info().getPit_number() + "", 1);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if (roomInfoResp.getUser_info().getPit_number() != 9) {
|
||||
// mBinding.imMkf.setVisibility(GONE);
|
||||
// } else {
|
||||
// mBinding.imMkf.setVisibility(VISIBLE);
|
||||
// }
|
||||
//
|
||||
// tzblChanged();
|
||||
}
|
||||
|
||||
mBinding.btSta.setOnClickListener(this::onClick);
|
||||
mBinding.btStop.setOnClickListener(this::onClick);
|
||||
mBinding.imMkf.setOnClickListener(this::onClick);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前用户是否是房间的主持人
|
||||
*
|
||||
@@ -536,28 +673,12 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: 2025/3/26 进入房间
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMainEvent(BaseEvent event){
|
||||
if (event instanceof RoomWheatEvent){
|
||||
//上麦模式变化通知 1自由2排麦
|
||||
if (roomId.equals(((RoomWheatEvent) event).getRoomId())) {
|
||||
roomInfoResp.getRoom_info().setWheat(((RoomWheatEvent) event).isFree() ? "1" : "2");
|
||||
}
|
||||
}else if (event instanceof RoomUpPitBean){
|
||||
if (((RoomUpPitBean) event).getPit_number() != null && !((RoomUpPitBean) event).getPit_number().equals("")) {
|
||||
RoomPitBean roomPitBean1 = GsonUtils.GsonToBean(GsonUtils.GsonString(event), RoomPitBean.class);
|
||||
RoomPitBean roomPitBean = roomInfoResp.getRoom_info().getPit_list().get(Integer.parseInt(((RoomUpPitBean) event).getTo_pit_number()) - 1);
|
||||
roomPitBean1.setPit_number(((RoomUpPitBean) event).getTo_pit_number());
|
||||
roomPitBean.setPit_number(((RoomUpPitBean) event).getPit_number());
|
||||
roomInfoResp.getRoom_info().getPit_list().set(Integer.parseInt(((RoomUpPitBean) event).getPit_number()) - 1, roomPitBean);
|
||||
roomInfoResp.getRoom_info().getPit_list().set(Integer.parseInt(((RoomUpPitBean) event).getTo_pit_number()) - 1, roomPitBean1);
|
||||
}
|
||||
updateWheatData();
|
||||
}else if (event instanceof RoomUserJoinModel){
|
||||
public void subscribeMessages(RoomUserJoinModel event) {
|
||||
Logger.e("@@@", "加入房间" + event);
|
||||
for (int i = 0; i < roomInfoResp.getRoom_info().getPit_list().size(); i++) {
|
||||
if (((RoomUserJoinModel) event).getUser_id().equals(roomInfoResp.getRoom_info().getPit_list().get(i).getUser_id())) {
|
||||
if (event.getUser_id().equals(roomInfoResp.getRoom_info().getPit_list().get(i).getUser_id())) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(roomInfoResp.getRoom_info().getPit_list().get(i).getEmchat_username());
|
||||
break;
|
||||
@@ -565,11 +686,15 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
}
|
||||
updateWheatData();
|
||||
}else if (event instanceof RoomOwnerLeaveEvent){
|
||||
}
|
||||
|
||||
// TODO: 2025/3/26 离开房间
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void subscribeMessages(RoomOwnerLeaveEvent event) {
|
||||
Logger.e("@@@", "离开房间" + event);
|
||||
if (roomInfoResp.getRoom_info().getFriend().getFriend_status() == 2) {
|
||||
for (int i = 0; i < roomInfoResp.getRoom_info().getPit_list().size(); i++) {
|
||||
if (((RoomOwnerLeaveEvent) event).getUser_id().equals(roomInfoResp.getRoom_info().getPit_list().get(i).getUser_id())) {
|
||||
if (event.getUser_id().equals(roomInfoResp.getRoom_info().getPit_list().get(i).getUser_id())) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(roomInfoResp.getRoom_info().getPit_list().get(i).getEmchat_username());
|
||||
break;
|
||||
@@ -579,12 +704,13 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
updateWheatData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void roomInfoUpdate(RoomInfoResp resp) {
|
||||
roomInfoResp = resp;
|
||||
roomId = roomInfoResp == null ? "" : roomInfoResp.getRoom_info().getRoom_id();
|
||||
// isWhether();
|
||||
upWheter();
|
||||
updateWheatData();
|
||||
}
|
||||
@@ -602,9 +728,32 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上麦模式变化通知 1自由2排麦
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void subscribeMessages(RoomWheatEvent roomWheatEvent) {
|
||||
if (roomId.equals(roomWheatEvent.getRoomId())) {
|
||||
roomInfoResp.getRoom_info().setWheat(roomWheatEvent.isFree() ? "1" : "2");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean aBoolean = false;
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onSwitchPitEvent(RoomUpPitBean event) {
|
||||
if (event.getPit_number() != null && !event.getPit_number().equals("")) {
|
||||
RoomPitBean roomPitBean1 = GsonUtils.GsonToBean(GsonUtils.GsonString(event), RoomPitBean.class);
|
||||
RoomPitBean roomPitBean = roomInfoResp.getRoom_info().getPit_list().get(Integer.parseInt(event.getTo_pit_number()) - 1);
|
||||
roomPitBean1.setPit_number(event.getTo_pit_number());
|
||||
roomPitBean.setPit_number(event.getPit_number());
|
||||
roomInfoResp.getRoom_info().getPit_list().set(Integer.parseInt(event.getPit_number()) - 1, roomPitBean);
|
||||
roomInfoResp.getRoom_info().getPit_list().set(Integer.parseInt(event.getTo_pit_number()) - 1, roomPitBean1);
|
||||
}
|
||||
updateWheatData();
|
||||
}
|
||||
|
||||
private boolean aBoolean = true;
|
||||
private int is_mute;
|
||||
|
||||
@Override
|
||||
@@ -613,8 +762,15 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
if (id == R.id.bt_sta) {
|
||||
PkTimeDialogFragment.show(roomInfoRespPk.getPk_info().getPk_id(), getChildFragmentManager());
|
||||
} else if (id == R.id.bt_stop) {
|
||||
if (roomInfoRespPk.getPk_info().getPk_part().equals("3") && pkStatus == 0) {
|
||||
//TODO 多次点击导致闪退
|
||||
if (roomInfoRespPk == null)
|
||||
return;
|
||||
if (pkStatus == 0) {
|
||||
if (roomInfoRespPk.getPk_info().getPk_part().equals("4")) {
|
||||
pkStutas();
|
||||
}else {
|
||||
pkStutasT();
|
||||
}
|
||||
} else {
|
||||
MvpPre.endPk(roomInfoRespPk.getPk_info().getPk_id(), "3", SpUtil.getUserId() + "");
|
||||
}
|
||||
@@ -623,19 +779,20 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
mBinding.imMkf.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone);
|
||||
is_mute = 0;
|
||||
aBoolean = false;
|
||||
AgoraManager.getInstance(getActivity()).muteAllRemoteAudioStreamsEx(false);
|
||||
AgoraManagerEx.getInstance(getActivity()).muteAllRemoteAudioStreamsExUserId(false);
|
||||
} else {
|
||||
mBinding.imMkf.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone_off);
|
||||
is_mute = 1;
|
||||
aBoolean = true;
|
||||
AgoraManager.getInstance(getActivity()).muteAllRemoteAudioStreamsEx(true);
|
||||
AgoraManagerEx.getInstance(getActivity()).muteAllRemoteAudioStreamsExUserId(true);
|
||||
}
|
||||
RoomMessageEvent.text text = new RoomMessageEvent.text();
|
||||
text.setIs_mute(is_mute);
|
||||
String s = com.blankj.utilcode.util.GsonUtils.toJson(text);
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setText(s);
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent(125, roomInfoResp.getPk_info().getPk_room_id(), t);
|
||||
if (roomInfoRespPk!=null && roomInfoRespPk.getPk_info() != null) {
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent(125, roomInfoResp.getRoom_info().getRoom_id(), t);
|
||||
String json = com.blankj.utilcode.util.GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
@@ -644,11 +801,12 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
roomInfoRespPk.getRoom_info().getPit_list().get(8).getUser_id(),
|
||||
binaryData
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int[] collectCurrentCardiacValues() {
|
||||
int[] cvs = new int[10];
|
||||
@@ -675,7 +833,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
@Override
|
||||
public void postRoomInfo(RoomInfoResp resp) {
|
||||
roomInfoResp = resp;
|
||||
createView(false);
|
||||
isWhether2(false);
|
||||
tzblChanged();
|
||||
}
|
||||
|
||||
@@ -690,12 +848,25 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
@Override
|
||||
public void postRoomInfoUp(RoomInfoResp resp) {
|
||||
roomInfoResp = resp;
|
||||
if (roomInfoRespPk != null) {
|
||||
getToView();
|
||||
}
|
||||
tzblChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endPk() {
|
||||
|
||||
//TODO 有多次进入的现象
|
||||
// if (roomInfoRespPk == null || roomInfoRespPk.getPk_info() == null)
|
||||
// return;
|
||||
// //释放定时器
|
||||
releaseCountDownTimer();
|
||||
//
|
||||
// AgoraManager.getInstance(getContext()).leaveChannelEx(roomInfoRespPk.getRoom_info().getRoom_id(), SpUtil.getUserId());
|
||||
// MvpPre.postRoomInfo(roomId, "0", 2);
|
||||
// mBinding.imStart2.setVisibility(GONE);
|
||||
// mBinding.imStart.setVisibility(GONE);
|
||||
// roomInfoRespPk = null;
|
||||
}
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
@@ -721,7 +892,31 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAgora(PkSwTokenBean pkSwTokenBean) {
|
||||
String pkUserId = "";
|
||||
String pkRoomId="";
|
||||
if (roomInfoRespPk.getPk_info() != null) {
|
||||
if (roomInfoRespPk.getPk_info().getInvite_pk_user_id().equals(SpUtil.getUserId()+"")) {
|
||||
pkUserId = roomInfoRespPk.getPk_info().getReceive_pk_user_id();
|
||||
|
||||
} else {
|
||||
pkUserId = roomInfoRespPk.getPk_info().getInvite_pk_user_id();
|
||||
}
|
||||
}
|
||||
LogUtils.e("pk_info", ""+pkUserId);
|
||||
LogUtils.e("pk_info", ""+roomInfoRespPk.getRoom_info().getRoom_id());
|
||||
LogUtils.e("pk_info2", ""+roomInfoResp.getRoom_info().getRoom_id());
|
||||
|
||||
AgoraManagerEx.getInstance(CommonAppContext.getInstance())
|
||||
.joinChannelEx(pkSwTokenBean.getAgora_token(), roomInfoRespPk.getRoom_info().getRoom_id(), pkUserId);
|
||||
// AgoraManager.getInstance(getView().getSelfActivity()).muteAllRemoteAudioStreamsExUserId(false, invite_pk_user_id);
|
||||
}
|
||||
|
||||
private void pkView() {
|
||||
if (wheatLayoutSingManager != null) {
|
||||
wheatLayoutSingManager.release();
|
||||
}
|
||||
mBinding.flexboxLayout.setVisibility(View.GONE);
|
||||
mBinding.cl.setVisibility(VISIBLE);
|
||||
FlexboxLayout flexboxLayout = mBinding.flexboxLayout1;
|
||||
@@ -729,7 +924,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
wheatLayoutManager1.setOnWheatClickListener(new WheatLayoutManager.OnWheatClickListener() {
|
||||
@Override
|
||||
public void onWheatClick(RoomDefaultWheatView view, int pitNumber1) {
|
||||
RoomPitBean pitBean = roomInfoResp.getRoom_info().getPit_list().get(pitNumber1 - 1);
|
||||
RoomPitBean pitBean = view.pitBean;
|
||||
// 可选:点击事件处理
|
||||
Log.d("Wheat", "Clicked pit: " + pitNumber1);
|
||||
if (!pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
@@ -762,7 +957,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
@Override
|
||||
public void onMakeWheatClick(RoomDefaultWheatView view, int pitNumber) {
|
||||
RoomPitBean pitBean = roomInfoRespPk.getRoom_info().getPit_list().get(pitNumber - 1);
|
||||
RoomPitBean pitBean = view.pitBean;
|
||||
|
||||
// 可选:点击事件处理
|
||||
Log.d("Wheat", "Clicked pit: " + pitNumber);
|
||||
@@ -799,7 +994,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
wheatLayoutManager2.setOnWheatClickListener(new WheatLayoutManager.OnWheatClickListener() {
|
||||
@Override
|
||||
public void onWheatClick(RoomDefaultWheatView view, int pitNumber1) {
|
||||
RoomPitBean pitBean = roomInfoResp.getRoom_info().getPit_list().get(pitNumber1 - 1);
|
||||
RoomPitBean pitBean = view.pitBean;
|
||||
|
||||
// 可选:点击事件处理
|
||||
Log.d("Wheat", "Clicked pit: " + pitNumber1);
|
||||
@@ -832,7 +1027,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
@Override
|
||||
public void onMakeWheatClick(RoomDefaultWheatView view, int pitNumber) {
|
||||
RoomPitBean pitBean = roomInfoRespPk.getRoom_info().getPit_list().get(pitNumber - 1);
|
||||
RoomPitBean pitBean = view.pitBean;
|
||||
|
||||
// 可选:点击事件处理
|
||||
Log.d("Wheat", "Clicked pit: " + pitNumber);
|
||||
@@ -840,7 +1035,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
if (isFastDoubleClick(pitBean.getUser_id(), pitBean.getPit_number())) {
|
||||
return;
|
||||
}
|
||||
RoomUserInfoFragment.show(roomInfoRespPk.getRoom_info().getRoom_id(), pitBean.getUser_id(), pitNumber + "", getHostUser(), true, 3, isNumberWhether(), getChildFragmentManager());
|
||||
RoomUserInfoFragment.show(roomInfoResp.getRoom_info().getRoom_id(), pitBean.getUser_id(), pitNumber + "", getHostUser(), true, 3, isNumberWhether(), getChildFragmentManager());
|
||||
// 点击的麦位是当前麦位
|
||||
// 可以执行相应的操作,如显示提示信息或执行其他逻辑
|
||||
}
|
||||
@@ -876,21 +1071,57 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
// 设置进度
|
||||
mBinding.pkProgress.setAnimProgress(progress);
|
||||
if (roomInfoResp.getUser_info().getPit_number() == 9) {
|
||||
mBinding.btStop.setVisibility(View.VISIBLE);
|
||||
|
||||
LogUtils.e("pk_info_1", "getToView: " + roomInfoRespPk.getPk_info());
|
||||
LogUtils.e("pk_info_2", "getToView: " + roomInfoResp.getPk_info());
|
||||
if (roomInfoResp.getPk_info()==null ){
|
||||
MvpPre.postRoomInfo(roomId, roomInfoResp.getUser_info().getPit_number() + "", 3);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Objects.equals(roomInfoRespPk.getUser_info().getUser_id(), roomInfoRespPk.getPk_info().getInvite_pk_user_id())) {
|
||||
mBinding.btStop.setVisibility(VISIBLE);
|
||||
mBinding.btSta.setVisibility(View.VISIBLE);
|
||||
if (roomInfoRespPk.getPk_info().getPk_part().equals("4")) {
|
||||
mBinding.btStop.setVisibility(INVISIBLE);
|
||||
mBinding.btStop.setVisibility(VISIBLE);
|
||||
}
|
||||
if (roomInfoResp.getPk_info() != null) {
|
||||
if (roomInfoResp.getPk_info().getPk_part().equals("3")) {
|
||||
if (roomInfoRespPk.getPk_info().getPk_part().equals("3")) {
|
||||
mBinding.btSta.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (roomInfoRespPk.getPk_info().getPk_part().equals("2")) {
|
||||
mBinding.btSta.setVisibility(VISIBLE);
|
||||
}
|
||||
}else if (roomInfoRespPk.getUser_info().getPit_number() == 9) {
|
||||
mBinding.btStop.setVisibility(VISIBLE);
|
||||
mBinding.btSta.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
mBinding.btStop.setVisibility(VISIBLE);
|
||||
mBinding.btSta.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
|
||||
if (Objects.equals(roomInfoResp.getUser_info().getUser_id(), roomInfoResp.getPk_info().getInvite_pk_user_id()!=null ? roomInfoResp.getPk_info().getInvite_pk_user_id():"0")) {
|
||||
|
||||
mBinding.btStop.setVisibility(VISIBLE);
|
||||
mBinding.btSta.setVisibility(View.VISIBLE);
|
||||
if (roomInfoRespPk.getPk_info().getPk_part().equals("4")) {
|
||||
mBinding.btStop.setVisibility(VISIBLE);
|
||||
}
|
||||
if (roomInfoRespPk.getPk_info().getPk_part().equals("3")) {
|
||||
mBinding.btSta.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (roomInfoRespPk.getPk_info().getPk_part().equals("2")) {
|
||||
mBinding.btSta.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
} else if (roomInfoResp.getUser_info().getPit_number() == 9) {
|
||||
mBinding.btStop.setVisibility(VISIBLE);
|
||||
mBinding.btSta.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
mBinding.btStop.setVisibility(INVISIBLE);
|
||||
mBinding.btSta.setVisibility(INVISIBLE);
|
||||
mBinding.btSta.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
releaseCountDownTimer();
|
||||
|
||||
if (roomInfoRespPk.getPk_info().getPk_part().equals("2")) {
|
||||
// mBinding.tvPkDjs.setText("等待开始");
|
||||
@@ -909,6 +1140,9 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
} else if (roomInfoRespPk.getPk_info().getPk_part().equals("4")) {
|
||||
countDownTime(Long.parseLong(roomInfoRespPk.getPk_info().getPk_end_times() != null ? roomInfoRespPk.getPk_info().getPk_end_times() : "0"), 2);
|
||||
}
|
||||
|
||||
mBinding.imMkf.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone);
|
||||
|
||||
}
|
||||
|
||||
// 添加一个方法来启动倒计时
|
||||
@@ -1001,13 +1235,11 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
mCountDownTimer.cancel();
|
||||
mCountDownTimer = null;
|
||||
|
||||
mBinding.tvPkDjs.setVisibility(GONE);
|
||||
|
||||
}
|
||||
if (mCountDownTimersta != null) {
|
||||
mCountDownTimersta.cancel();
|
||||
mCountDownTimersta = null;
|
||||
mBinding.tvPkDjs.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,7 +1271,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
}
|
||||
wheatLayoutSingManager.updateSingleWheat(pitBean, Integer.parseInt(pitBean.getPit_number()));
|
||||
} else {
|
||||
wheatLayoutManager1.updateSingleWheat(pitBean, Integer.parseInt(pitBean.getPit_number()));
|
||||
wheatLayoutManager1.updateSingleWheat(pitBean, Integer.parseInt(pitBean.getPit_number()), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1060,7 +1292,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
wheatLayoutSingManager.updateSingleWheat(pitBean, Integer.parseInt(pitBean.getPit_number() != null ? roomPitBean.getPit_number() : "0"));
|
||||
}
|
||||
} else {
|
||||
wheatLayoutManager1.updateSingleWheat(pitBean, Integer.parseInt(pitBean.getPit_number()));
|
||||
wheatLayoutManager1.updateSingleWheat(pitBean, Integer.parseInt(pitBean.getPit_number()), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1072,9 +1304,15 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
wheatLayoutSingManager.setUpData(message);
|
||||
} else {
|
||||
for (int i = 0; i < roomInfoResp.getRoom_info().getPit_list().size(); i++) {
|
||||
wheatLayoutManager1.updateSingleWheat(roomInfoResp.getRoom_info().getPit_list().get(i), i + 1);
|
||||
if (message.getText().getIs_pk() == null) {
|
||||
wheatLayoutManager1.setUpData(message, 1);
|
||||
} else {
|
||||
wheatLayoutManager2.setUpData(message, 2);
|
||||
|
||||
}
|
||||
// for (int i = 0; i < roomInfoResp.getRoom_info().getPit_list().size(); i++) {
|
||||
// wheatLayoutManager1.updateSingleWheat(roomInfoResp.getRoom_info().getPit_list().get(i), i + 1);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1103,7 +1341,11 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
// ((RoomActivity) getActivity()).ivSoundEffects(true);
|
||||
// }
|
||||
// }
|
||||
wheatLayoutManager1.updateSingleWheat(pitBean, Integer.parseInt(message.getText().getPit_number()));
|
||||
if (message.getText().getIs_pk() == null) {
|
||||
wheatLayoutManager1.updateSingleWheat(pitBean, Integer.parseInt(message.getText().getPit_number()), 1);
|
||||
} else {
|
||||
wheatLayoutManager2.updateSingleWheat(pitBean, Integer.parseInt(message.getText().getPit_number()), 2);
|
||||
}
|
||||
}
|
||||
// 通知父 Fragment
|
||||
if (SpUtil.getUserId() == message.getText().getFromUserInfo().getUser_id()) {
|
||||
@@ -1130,9 +1372,23 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
pitBean.setDress("");
|
||||
roomInfoResp.getRoom_info().getPit_list().set(Integer.parseInt(message.getText().getPit_number()) - 1, pitBean);
|
||||
if (roomInfoRespPk == null || roomInfoRespPk.getPk_info() == null) {
|
||||
// if (pitBean.getPit_number().equals("9")){
|
||||
// if (getActivity() instanceof RoomActivity) {
|
||||
// ((RoomActivity) getActivity()).ivSoundEffects(false);
|
||||
// }
|
||||
// }
|
||||
wheatLayoutSingManager.updateSingleWheat(pitBean, Integer.parseInt(message.getText().getPit_number()));
|
||||
} else {
|
||||
wheatLayoutManager1.updateSingleWheat(pitBean, Integer.parseInt(message.getText().getPit_number()));
|
||||
// if (pitBean.getPit_number().equals("9")){
|
||||
// if (getActivity() instanceof RoomActivity) {
|
||||
// ((RoomActivity) getActivity()).ivSoundEffects(false);
|
||||
// }
|
||||
// }
|
||||
if (message.getText().getIs_pk() == null) {
|
||||
wheatLayoutManager1.updateSingleWheat(pitBean, Integer.parseInt(message.getText().getPit_number()), 1);
|
||||
} else {
|
||||
wheatLayoutManager2.updateSingleWheat(pitBean, Integer.parseInt(message.getText().getPit_number()), 2);
|
||||
}
|
||||
}
|
||||
if (SpUtil.getUserId() == message.getText().getFromUserInfo().getUser_id()) {
|
||||
b = true;
|
||||
@@ -1187,7 +1443,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
for (RoomPitBean pitBean : roomInfoRespPk.getRoom_info().getPit_list()) {
|
||||
if (pitBean.getUser_id().equals(userId)) {
|
||||
pitBean.setCharm(charm);
|
||||
wheatLayoutManager2.updateSingleCharm(pitBean, Integer.parseInt(pitBean.getPit_number()));
|
||||
wheatLayoutManager2.updateSingleCharm(pitBean, Integer.parseInt(pitBean.getPit_number()), 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1196,7 +1452,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
for (RoomPitBean pitBean : roomInfoResp.getRoom_info().getPit_list()) {
|
||||
if (pitBean.getUser_id().equals(userId)) {
|
||||
pitBean.setCharm(charm);
|
||||
wheatLayoutManager1.updateSingleCharm(pitBean, Integer.parseInt(pitBean.getPit_number()));
|
||||
wheatLayoutManager1.updateSingleCharm(pitBean, Integer.parseInt(pitBean.getPit_number()), 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1205,14 +1461,10 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
/// 1030
|
||||
public void event1030(RoomMessageEvent message) {
|
||||
|
||||
MvpPre.postRoomInfo(message.getRoomId(), roomInfoResp.getUser_info().getPit_number() + "", 3);
|
||||
if (message.getText().getType() == 1) {
|
||||
MvpPre.postRoomInfo(message.getText().getRoom_id(), roomInfoResp.getUser_info().getPit_number() + "", 1);
|
||||
if (message.getText().getRoom_id().equals(roomId)) {
|
||||
mBinding.btSta.setVisibility(VISIBLE);
|
||||
} else {
|
||||
mBinding.btSta.setVisibility(INVISIBLE);
|
||||
}
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).setRoleType(5, -11);
|
||||
}
|
||||
@@ -1233,7 +1485,14 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
/// 1033
|
||||
public void event1033(RoomMessageEvent message) {
|
||||
AgoraManager.getInstance(getContext()).leaveChannelEx(roomInfoRespPk.getRoom_info().getRoom_id(), SpUtil.getUserId());
|
||||
//TODO 有多次进入的现象
|
||||
if (roomInfoRespPk == null || roomInfoRespPk.getPk_info() == null)
|
||||
return;
|
||||
//释放定时器
|
||||
releaseCountDownTimer();
|
||||
if (roomInfoRespPk.getRoom_info() != null && roomInfoRespPk.getRoom_info().getRoom_id() != null) {
|
||||
AgoraManagerEx.getInstance(getContext()).leaveChannelEx(roomInfoRespPk.getRoom_info().getRoom_id(), SpUtil.getUserId());
|
||||
}
|
||||
MvpPre.postRoomInfo(roomId, "0", 2);
|
||||
mBinding.imStart2.setVisibility(GONE);
|
||||
mBinding.imStart.setVisibility(GONE);
|
||||
@@ -1242,7 +1501,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
|
||||
/// 1037
|
||||
public void event1037(RoomMessageEvent message) {
|
||||
if (message.getText().getPit_number().equals("9") && message.getText().getFromUserInfo().getUser_id() == SpUtil.getUserId()) {
|
||||
if (roomInfoResp.getUser_info().getPit_number() == 9 && roomInfoRespPk.getPk_info().getInvite_pk_user_id().equals(message.getText().getFromUserInfo().getUser_id()+"")) {
|
||||
queren();
|
||||
}
|
||||
}
|
||||
@@ -1318,6 +1577,22 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
}, false, 0).show();
|
||||
}
|
||||
|
||||
private void pkStutasT() {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(getActivity(),
|
||||
"提示",
|
||||
"是否提前结束本场PK?",
|
||||
"确认",
|
||||
"取消",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
MvpPre.endPk(roomInfoRespPk.getPk_info().getPk_id(), "3", SpUtil.getUserId() + "");
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
}, false, 0).show();
|
||||
}
|
||||
|
||||
private int pkStatus;
|
||||
|
||||
private void ivitTop(RoomMessageEvent message) {
|
||||
@@ -1337,6 +1612,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
mBinding.imStart.setImageResource(com.xscm.moduleutil.R.mipmap.ping);
|
||||
mBinding.imStart2.setImageResource(com.xscm.moduleutil.R.mipmap.ping);
|
||||
}
|
||||
roomInfoRespPk.getPk_info().setPk_part("4");
|
||||
countDownTime(Long.parseLong(message.getText().getEnd_time()), 2);
|
||||
}
|
||||
|
||||
@@ -1406,6 +1682,11 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
}
|
||||
};
|
||||
|
||||
// btnKnow.setOnClickListener(v -> {
|
||||
// countDownTimer.cancel(); // 取消倒计时
|
||||
// dialog.dismiss(); // 手动关闭对话框
|
||||
// });
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
@@ -1418,6 +1699,13 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
||||
lp.copyFrom(dialog.getWindow().getAttributes());
|
||||
lp.width = (int) (context.getResources().getDisplayMetrics().widthPixels * 0.9f); // 80% 屏幕宽度
|
||||
int maxHeightDp = 200; // 最大高度 200dp
|
||||
int maxHeightPx = (int) (maxHeightDp * context.getResources().getDisplayMetrics().density);
|
||||
|
||||
// lp.height = Math.min(
|
||||
// maxHeightPx,
|
||||
// context.getResources().getDisplayMetrics().heightPixels * 3 / 5
|
||||
// ); // 取较小值
|
||||
dialog.getWindow().setAttributes(lp);
|
||||
}
|
||||
|
||||
@@ -1449,9 +1737,12 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
}
|
||||
mBinding.flexboxLayout.removeAllViews();
|
||||
mBinding.flexboxLayout2.removeAllViews();
|
||||
|
||||
if (sharedViewModel != null) {
|
||||
sharedViewModel.clearChildFragmentData();
|
||||
}
|
||||
if (MvpPre != null) {
|
||||
MvpPre.detachView();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class VoiceFragment extends BaseMvpFragment<VoicePresenter, FragmentVoice
|
||||
|
||||
mBinding.ivRoom.setOnClickListener(v -> {
|
||||
//我的房间
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).navigation();
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).withFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).navigation();
|
||||
});
|
||||
|
||||
// mBinding.ivRoom2.setOnClickListener(v -> {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.SingSongContacts;
|
||||
import com.xscm.moduleutil.base.BaseRoomPresenter;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
@@ -93,8 +94,9 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||
String token = roomInfoResp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||
if (roomInfoResp==null){
|
||||
return;
|
||||
}
|
||||
String roomId = roomInfoResp.getRoom_info().getRoom_id(); // 房间 ID
|
||||
String rtm_token = roomInfoResp.getUser_info().getAgora_rtm_token();
|
||||
SpUtil.setRtmToken(rtm_token);
|
||||
@@ -103,16 +105,18 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
|
||||
if (type==1) {
|
||||
if (roomInfoResp.getPk_info() != null) {
|
||||
if (number.equals("9")) {
|
||||
postRoomSwToken(roomId,uid);
|
||||
LogUtils.e("pk_info", ""+number);
|
||||
postRoomSwToken(roomId,uid,roomInfoResp.getPk_info().getInvite_pk_user_id());
|
||||
///添加多频道
|
||||
}
|
||||
}
|
||||
MvpRef.get().postRoomInfoPk(roomInfoResp);
|
||||
// postRoomInfo(SpUtil.getMyRoomId(),"9",3);
|
||||
}else if (type==3){
|
||||
AgoraManager.getInstance(getView().getSelfActivity()).leaveChannelEx(roomInfoResp.getRoom_info().getLast_pk_room_id()+"", uid);
|
||||
// AgoraManagerEx.getInstance(getView().getSelfActivity()).leaveChannelEx(roomInfoResp.getRoom_info().getLast_pk_room_id()+"", uid);
|
||||
MvpRef.get().postRoomInfoUp(roomInfoResp);
|
||||
}else {
|
||||
AgoraManager.getInstance(getView().getSelfActivity()).leaveChannelEx(roomInfoResp.getRoom_info().getLast_pk_room_id()+"", uid);
|
||||
// AgoraManagerEx.getInstance(getView().getSelfActivity()).leaveChannelEx(roomInfoResp.getRoom_info().getLast_pk_room_id()+"", uid);
|
||||
MvpRef.get().postRoomInfo(roomInfoResp);
|
||||
}
|
||||
|
||||
@@ -156,7 +160,7 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
|
||||
});
|
||||
}
|
||||
|
||||
public void postRoomSwToken(String roomId,int uid) {
|
||||
public void postRoomSwToken(String roomId,int uid,String invite_pk_user_id) {
|
||||
RetrofitClient.getInstance().postRoomSwToken(roomId, new BaseObserver<PkSwTokenBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -167,8 +171,14 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
|
||||
public void onNext(PkSwTokenBean pkSwTokenBean) {
|
||||
if (pkSwTokenBean!=null){
|
||||
if (pkSwTokenBean.getAgora_token() != null){
|
||||
AgoraManager.getInstance(getView().getSelfActivity())
|
||||
.joinChannelEx(pkSwTokenBean.getAgora_token(), roomId, uid);
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().postAgora(pkSwTokenBean);
|
||||
|
||||
// AgoraManager.getInstance(getView().getSelfActivity())
|
||||
// .joinChannelEx(pkSwTokenBean.getAgora_token(), roomId, uid);
|
||||
// AgoraManager.getInstance(getView().getSelfActivity()).muteAllRemoteAudioStreamsExUserId(false, invite_pk_user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ public class CreatedRoomActivity extends BaseMvpActivity<CreatedRoomPresenter, A
|
||||
|
||||
@Override
|
||||
public void checkTxtSuccess(String result) {
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).navigation();
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).withFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).navigation();
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ public class CreatedRoomActivity extends BaseMvpActivity<CreatedRoomPresenter, A
|
||||
|
||||
@Override
|
||||
public void editRoom() {
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).navigation();
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).withFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).navigation();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,14 @@ package com.xscm.modulemain.activity.user.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.util.SparseArray;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@@ -16,6 +19,7 @@ import androidx.viewpager.widget.ViewPager;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.main.activity.MainActivity;
|
||||
import com.xscm.modulemain.databinding.RoomActivityMyRoomBinding;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.modulemain.activity.user.conacts.MyRoomListContacts;
|
||||
@@ -58,6 +62,37 @@ public class MyRoomActivity extends BaseMvpActivity<MyRoomPresenter, RoomActivit
|
||||
return new MyRoomPresenter(this, this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
// 拦截返回键,显示退出对话框而不是直接退出
|
||||
singleTaskToActivity(MainActivity.class);
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 添加返回键拦截处理
|
||||
if (getOnBackPressedDispatcher() != null) {
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
// 拦截返回键,导航到个人中心页面而不是直接退出
|
||||
singleTaskToActivity(MainActivity.class);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.viewPager.setAdapter(new MyFragmentAdapter(getSupportFragmentManager()));
|
||||
@@ -194,6 +229,15 @@ public class MyRoomActivity extends BaseMvpActivity<MyRoomPresenter, RoomActivit
|
||||
isShowLoading(true);
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), CommonAppContext.getInstance().playId, "",null);
|
||||
});
|
||||
|
||||
mBinding.topBar.getIvBack().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
singleTaskToActivity(MainActivity.class);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.ivGuanbi.setOnClickListener(v -> {
|
||||
mBinding.ll.setVisibility(View.INVISIBLE);
|
||||
CommonAppContext.getInstance().isShow = false;
|
||||
|
||||
@@ -212,7 +212,13 @@ public class RoomPkDialogFragment extends BaseMvpDialogFragment<RoomPkPresenter,
|
||||
|
||||
@Override
|
||||
public void searchPkRoom(List<RoomBean> roomBeans) {
|
||||
if (page==1) {
|
||||
mAdapter.setNewData(roomBeans);
|
||||
}else {
|
||||
if (roomBeans!=null) {
|
||||
mAdapter.addData(roomBeans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -98,10 +98,10 @@ public class RoomManager {
|
||||
|
||||
if (roomInfo != null) {
|
||||
// 使用缓存数据直接进入房间
|
||||
navigateToRoom(context, roomId, password, roomInfo, false,null);
|
||||
navigateToRoom(context, roomId, password, roomInfo, false, null);
|
||||
} else {
|
||||
// 获取房间数据后进入房间
|
||||
fetchRoomDataAndEnter(context, roomId, password,null);
|
||||
fetchRoomDataAndEnter(context, roomId, password, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,36 +112,36 @@ public class RoomManager {
|
||||
* @param roomId 房间ID
|
||||
* @param password 房间密码
|
||||
*/
|
||||
public void fetchRoomDataAndEnter(Context context, String roomId, String password,String taskId) {
|
||||
public void fetchRoomDataAndEnter(Context context, String roomId, String password, String taskId) {
|
||||
// 显示加载提示
|
||||
// 这里可以根据需要添加加载对话框
|
||||
if (CommonAppContext.getInstance().isRoomJoininj){
|
||||
if (CommonAppContext.getInstance().isRoomJoininj) {
|
||||
return;
|
||||
}
|
||||
CommonAppContext.getInstance().isRoomJoininj=true;
|
||||
CommonAppContext.getInstance().isRoomJoininj = true;
|
||||
// 检查是否有有效的缓存数据
|
||||
RoomInfoResp roomInfo = getCachedRoomData(roomId);
|
||||
// 检查是否是当前房间且用户在线
|
||||
// boolean isCurrentRoom = isCurrentRoom(roomId);
|
||||
if (CommonAppContext.getInstance().playId == null) {
|
||||
fetchAndJoinRoom(context, roomId, password,taskId);
|
||||
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;
|
||||
CommonAppContext.getInstance().isRoomJoininj = false;
|
||||
EventBus.getDefault().post(new RoomOutEvent());
|
||||
} else if (CommonAppContext.getInstance().lable_id.equals("6")) {
|
||||
upInfo(context, roomId, password, true, roomInfo, true,taskId);
|
||||
upInfo(context, roomId, password, true, roomInfo, true, taskId);
|
||||
return;
|
||||
}
|
||||
isUserOnline(context, roomId, password, roomInfo,taskId);
|
||||
isUserOnline(context, roomId, password, roomInfo, taskId);
|
||||
}
|
||||
}
|
||||
|
||||
private void upInfo(Context context, String roomId, String password, boolean isOnline, RoomInfoResp roomInfo, boolean isCurrentRoom,String taskId) {
|
||||
private void upInfo(Context context, String roomId, String password, boolean isOnline, RoomInfoResp roomInfo, boolean isCurrentRoom, String taskId) {
|
||||
if (isOnline) {
|
||||
RetrofitClient.getInstance().postRoomInfo(roomId, new BaseObserver<RoomInfoResp>() {
|
||||
|
||||
@@ -152,11 +152,11 @@ public class RoomManager {
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull RoomInfoResp roomInfoResp) {
|
||||
navigateToRoom(context, roomId, password, roomInfoResp, false,taskId);
|
||||
navigateToRoom(context, roomId, password, roomInfoResp, false, taskId);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fetchAndJoinRoom(context, roomId, password,taskId);
|
||||
fetchAndJoinRoom(context, roomId, password, taskId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public class RoomManager {
|
||||
* @param roomId 房间ID
|
||||
* @param password 房间密码
|
||||
*/
|
||||
private void fetchAndJoinRoom(Context context, String roomId, String password,String taskId) {
|
||||
private void fetchAndJoinRoom(Context context, String roomId, String password, String taskId) {
|
||||
// 获取房间数据
|
||||
RetrofitClient.getInstance().roomGetIn(roomId, password, new BaseObserver<RoomInfoResp>() {
|
||||
|
||||
@@ -177,6 +177,7 @@ 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
|
||||
@@ -194,7 +195,8 @@ public class RoomManager {
|
||||
AgoraManager.getInstance(context)
|
||||
.joinRoom(token, roomId, uid, enableMic, enableJs);
|
||||
cacheRoomData(roomId, resp);
|
||||
navigateToRoom(context, roomId, password, resp, false,taskId);
|
||||
navigateToRoom(context, roomId, password, resp, false, taskId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -235,7 +237,7 @@ public class RoomManager {
|
||||
* @param password 房间密码
|
||||
* @param roomInfo 房间信息
|
||||
*/
|
||||
private void navigateToRoom(Context context, String roomId, String password, RoomInfoResp roomInfo, boolean isOnline,String taskId) {
|
||||
private void navigateToRoom(Context context, String roomId, String password, RoomInfoResp roomInfo, boolean isOnline, String taskId) {
|
||||
|
||||
try {
|
||||
// 构建跳转参数
|
||||
@@ -246,11 +248,11 @@ public class RoomManager {
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
intent.putExtra("password", password);
|
||||
}
|
||||
if (taskId != null){
|
||||
if (taskId != null) {
|
||||
intent.putExtra("taskId", taskId);
|
||||
}
|
||||
|
||||
if (roomInfo == null){
|
||||
if (roomInfo == null) {
|
||||
LogUtils.dTag("RoomActivity", "navigateToRoom:房间信息获取存在问题");
|
||||
return;
|
||||
}
|
||||
@@ -312,7 +314,7 @@ public class RoomManager {
|
||||
* @param roomId 房间ID
|
||||
* @return true表示用户在线,false表示不在线
|
||||
*/
|
||||
private boolean isUserOnline(Context context, String roomId, String password, RoomInfoResp roomInfo,String taskId) {
|
||||
private boolean isUserOnline(Context context, String roomId, String password, RoomInfoResp roomInfo, String taskId) {
|
||||
// 这里应该实现检查用户是否在线的逻辑
|
||||
// 可以通过检查Agora是否还在房间中,或者通过服务端接口查询用户状态等方式实现
|
||||
// 目前返回false,需要根据实际需求实现具体逻辑
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
android:background="#4d000000"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<!-- <View-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
@@ -77,7 +77,7 @@
|
||||
app:lineSpacing="8dp"
|
||||
app:startOfVerseIndicatorPaddingTop="6dp"
|
||||
app:startOfVerseIndicatorRadius="4dp"
|
||||
app:textSize="@dimen/sp_12" />
|
||||
app:textSize="@dimen/sp_12"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mu_title"
|
||||
@@ -89,7 +89,7 @@
|
||||
android:textColor="@color/color_FFFFF0F0"
|
||||
android:textSize="@dimen/sp_12"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mu_name"
|
||||
@@ -107,7 +107,7 @@
|
||||
android:textSize="@dimen/sp_12"
|
||||
app:layout_constraintStart_toEndOf="@+id/mu_title"
|
||||
app:layout_constraintTop_toTopOf="@+id/mu_title"
|
||||
tools:text="歌曲名称" />
|
||||
tools:text="歌曲名称"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/ll_u_b"
|
||||
@@ -127,7 +127,7 @@
|
||||
android:layout_height="@dimen/dp_25"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@mipmap/default_avatar"
|
||||
app:riv_oval="true" />
|
||||
app:riv_oval="true"/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
android:textColor="@color/color_FFFFF0F0"
|
||||
android:textSize="@dimen/sp_12"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mu_x_name"
|
||||
@@ -158,7 +158,7 @@
|
||||
android:textSize="@dimen/sp_12"
|
||||
app:layout_constraintStart_toEndOf="@+id/mu_x_title"
|
||||
app:layout_constraintTop_toTopOf="@+id/mu_x_title"
|
||||
tools:text="歌曲名称" />
|
||||
tools:text="歌曲名称"/>
|
||||
|
||||
<com.xscm.moduleutil.widget.RoomKtvWheatView
|
||||
android:id="@+id/mu_yc"
|
||||
@@ -167,7 +167,7 @@
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:room_wheat_number="-1" />
|
||||
app:room_wheat_number="-1"/>
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
android:id="@+id/fl_pit_container"
|
||||
@@ -195,7 +195,7 @@
|
||||
android:layout_width="@dimen/dp_13"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_gravity="center"
|
||||
android:src="@mipmap/accompany_on" />
|
||||
android:src="@mipmap/accompany_on"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_bz"
|
||||
@@ -205,7 +205,7 @@
|
||||
android:gravity="center"
|
||||
android:text="原唱"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/sp_10" />
|
||||
android:textSize="@dimen/sp_10"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@@ -220,7 +220,7 @@
|
||||
android:layout_width="@dimen/dp_13"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_gravity="center"
|
||||
android:src="@mipmap/muisc_reward" />
|
||||
android:src="@mipmap/muisc_reward"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="@dimen/dp_20"
|
||||
@@ -229,7 +229,7 @@
|
||||
android:gravity="center"
|
||||
android:text="打赏"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="@dimen/sp_10" />
|
||||
android:textSize="@dimen/sp_10"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@@ -244,7 +244,7 @@
|
||||
android:layout_width="@dimen/dp_13"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_gravity="center"
|
||||
android:src="@mipmap/muisc_switch" />
|
||||
android:src="@mipmap/muisc_switch"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="@dimen/dp_20"
|
||||
@@ -253,7 +253,7 @@
|
||||
android:gravity="center"
|
||||
android:text="切歌"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="@dimen/sp_10" />
|
||||
android:textSize="@dimen/sp_10"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@@ -268,7 +268,7 @@
|
||||
android:layout_width="@dimen/dp_13"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_gravity="center"
|
||||
android:src="@mipmap/muisc_end" />
|
||||
android:src="@mipmap/muisc_end"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="@dimen/dp_20"
|
||||
@@ -277,7 +277,7 @@
|
||||
android:gravity="center"
|
||||
android:text="结束"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="@dimen/sp_10" />
|
||||
android:textSize="@dimen/sp_10"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@@ -293,7 +293,7 @@
|
||||
android:layout_width="@dimen/dp_13"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_gravity="center"
|
||||
android:src="@mipmap/muisc_set_up" />
|
||||
android:src="@mipmap/muisc_set_up"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="@dimen/dp_20"
|
||||
@@ -302,7 +302,7 @@
|
||||
android:gravity="center"
|
||||
android:text="设置"
|
||||
android:textColor="@color/color_0DFFB9"
|
||||
android:textSize="@dimen/sp_10" />
|
||||
android:textSize="@dimen/sp_10"/>
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -314,7 +314,7 @@
|
||||
android:id="@+id/mu_zc"
|
||||
android:layout_width="@dimen/dp_62"
|
||||
android:layout_height="@dimen/dp_88"
|
||||
android:layout_marginTop="-55dp"
|
||||
android:layout_marginTop="-25dp"
|
||||
android:layout_marginEnd="@dimen/dp_5"
|
||||
android:clickable="true"
|
||||
android:elevation="9999dp"
|
||||
@@ -325,7 +325,8 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/cl_bj"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:room_wheat_number="9" />
|
||||
app:room_wheat_number="9"
|
||||
/>
|
||||
<!-- 在 mu_zc 视图后面添加 -->
|
||||
<!-- <View-->
|
||||
<!-- android:id="@+id/mu_zc_touch_overlay"-->
|
||||
@@ -345,22 +346,26 @@
|
||||
android:id="@+id/mu_jb"
|
||||
android:layout_width="@dimen/dp_62"
|
||||
android:layout_height="@dimen/dp_88"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:layout_marginTop="@dimen/dp_5"
|
||||
android:layout_marginEnd="@dimen/dp_5"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/cl_bj"
|
||||
app:layout_constraintTop_toBottomOf="@+id/mu_zc"
|
||||
app:room_wheat_number="10" />
|
||||
app:room_wheat_number="10"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="@dimen/dp_62"
|
||||
android:layout_width="@dimen/dp_58"
|
||||
android:layout_height="0dp"
|
||||
android:paddingEnd="@dimen/dp_5"
|
||||
android:layout_marginBottom="-100dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHeight_default="wrap"
|
||||
app:layout_constraintStart_toEndOf="@+id/cl_bj"
|
||||
app:layout_constraintTop_toBottomOf="@+id/mu_jb" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/mu_jb"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bt_stop"
|
||||
android:text="未开始:04:25"
|
||||
tools:text="未开始:04:25"
|
||||
android:textSize="@dimen/sp_12"
|
||||
android:textColor="@color/white"
|
||||
android:background="@mipmap/pk_djs"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
android:id="@+id/mu_rank"
|
||||
android:layout_width="@dimen/dp_62"
|
||||
android:layout_height="@dimen/dp_88"
|
||||
app:layout_constraintDimensionRatio="1:1.2"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="@dimen/dp_172"
|
||||
android:layout_width="@dimen/dp_152"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
||||
@@ -256,43 +256,58 @@
|
||||
android:visibility="invisible"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
|
||||
<!-- android:id="@+id/cl_xsb"-->
|
||||
<!-- android:layout_width="@dimen/dp_60"-->
|
||||
<!-- android:layout_height="@dimen/dp_25"-->
|
||||
<!-- android:layout_marginStart="@dimen/dp_8"-->
|
||||
<!-- android:layout_alignParentEnd="true"-->
|
||||
<!-- android:layout_alignTop="@id/btn_notice"-->
|
||||
<!-- tools:visibility="visible">-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/iv_first_charge"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- android:scaleType="fitCenter"-->
|
||||
<!-- android:src="@mipmap/room_xsb"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
||||
<com.xscm.moduleutil.widget.RoomKtvWheatView
|
||||
android:id="@+id/mu_zc"
|
||||
android:layout_width="@dimen/dp_62"
|
||||
android:layout_height="@dimen/dp_88"
|
||||
android:layout_marginEnd="@dimen/dp_20"
|
||||
android:layout_marginTop="@dimen/dp_35"
|
||||
android:clickable="true"
|
||||
android:elevation="9999dp"
|
||||
android:focusable="true"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:translationZ="30dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
app:room_wheat_number="9"
|
||||
android:visibility="gone"/>
|
||||
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tv_first"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:textColor="#FFFFFF"-->
|
||||
<!-- android:paddingEnd="@dimen/dp_2"-->
|
||||
<!-- android:textSize="11sp"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="parent"-->
|
||||
<!-- android:text="小时榜" />-->
|
||||
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
|
||||
<!-- android:id="@+id/cl_xsb"-->
|
||||
<!-- android:layout_width="@dimen/dp_60"-->
|
||||
<!-- android:layout_height="@dimen/dp_25"-->
|
||||
<!-- android:layout_marginStart="@dimen/dp_8"-->
|
||||
<!-- android:layout_alignParentEnd="true"-->
|
||||
<!-- android:layout_alignTop="@id/btn_notice"-->
|
||||
<!-- tools:visibility="visible">-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/iv_first_charge"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- android:scaleType="fitCenter"-->
|
||||
<!-- android:src="@mipmap/room_xsb"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
||||
|
||||
|
||||
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tv_first"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:textColor="#FFFFFF"-->
|
||||
<!-- android:paddingEnd="@dimen/dp_2"-->
|
||||
<!-- android:textSize="11sp"-->
|
||||
<!-- android:gravity="center"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toTopOf="parent"-->
|
||||
<!-- android:text="小时榜" />-->
|
||||
|
||||
|
||||
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user