合并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) {
|
||||
if (pitList == null || pitList.isEmpty() || pitNumber < 1 || pitNumber > 10) return;
|
||||
if (isSingleMode && this.currentSinglePit != pitNumber) return;
|
||||
toWheatView.setData(fromPitBean);
|
||||
fromWheatView.setData(toPitBean);
|
||||
|
||||
RoomDefaultWheatView wheatView = findWheatViewByPitNumber(pitNumber);
|
||||
if (wheatView != null) {
|
||||
wheatView.setData(pitBean);
|
||||
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 updateSingleCharm(RoomPitBean pitBean, int pitNumber) {
|
||||
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) {
|
||||
wheatView.setCharm(pitBean.getCharm());
|
||||
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,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) {
|
||||
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" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user