1、删除融云RTC功能,app能跑起来了。但是游戏IM出问题

This commit is contained in:
老皮 2024-09-23 15:59:41 +08:00
parent f823f17bca
commit 03b05d0de0
38 changed files with 149 additions and 13329 deletions

View File

@ -38,9 +38,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCVideoOutputFrameListener;
import cn.rongcloud.rtc.base.RCRTCVideoFrame;
/**
* 美颜模块管理类
@ -178,44 +175,6 @@ public class FaceManager implements SensorEventListener {
private static final int CAMERA_SWITCH_SKIP_FRAME = 0;
private volatile boolean mSkip;
/**
* 渲染融云视频帧
*/
public void drawRongFrame(Context context) {
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(new IRCRTCVideoOutputFrameListener() {
@Override
public RCRTCVideoFrame processVideoFrame(RCRTCVideoFrame callVideoFrame) {
//Log.i(TAG, "processVideoFrame: egl context " + EGL14.eglGetCurrentContext());
if (pauseFace) {
return callVideoFrame;
}
int width = callVideoFrame.getWidth();
int height = callVideoFrame.getHeight();
if (mIsFirstFrame) {
mIsFirstFrame = false;
//initCsvUtil(context);
mFURenderer.prepareRenderer(mFURendererListener);
}
//long start = System.nanoTime();
mFURenderer.setInputOrientation(callVideoFrame.getRotation());
FURenderOutputData data = mFURenderer.onDrawFrameInputWithReturn(callVideoFrame.getData(), width, height);
/* long time = System.nanoTime() - start;
if (mCSVUtils != null) {
mCSVUtils.writeCsv(null, time);
}*/
if (mSkippedFrames > 0 || mSkip) {
--mSkippedFrames;
return callVideoFrame;
}
if (data != null && data.getImage() != null && data.getImage().getBuffer() != null) {
callVideoFrame.setData(data.getImage().getBuffer());
}
return callVideoFrame;
}
});
}
/**
* 记录渲染工具调试用在processVideoFrame里使用
@ -278,12 +237,6 @@ public class FaceManager implements SensorEventListener {
}
/**
* 离开渲染界面时注销融云监听器不然会绿屏
*/
public void onClose() {
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(null);
}
/**
* 释放资源

View File

@ -5,8 +5,6 @@ import static com.yunbao.live.socket.SocketClient.mSocketHandler;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.http.HttpResponseCache;
import android.os.Build;
import android.os.Bundle;
@ -27,7 +25,6 @@ import com.blankj.utilcode.util.Utils;
import com.facebook.appevents.AppEventsLogger;
import com.fm.openinstall.OpenInstall;
import com.google.gson.Gson;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DebugUtils;
import com.yunbao.common.utils.LogUtils;
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
@ -54,7 +51,6 @@ import com.yunbao.common.utils.GoogleUtils;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.live.socket.SocketReceiveBean;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.utils.LiveImDeletUtil;
import com.yunbao.live.views.PortraitLiveManager;
@ -246,7 +242,7 @@ public class AppContext extends CommonAppContext {
}
//融云
if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
/* if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketRyClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
@ -265,7 +261,7 @@ public class AppContext extends CommonAppContext {
//主播页面
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.sendMessage(msg);
}
}*/
} else if (message.getConversationType() == Conversation.ConversationType.PRIVATE) {//私聊信息
EventBus.getDefault().post(message);
}

View File

@ -178,7 +178,7 @@ dependencies {
//im
api 'com.tencent.imsdk:imsdk-plus:5.4.666'
api 'com.google.code.gson:gson:2.8.8'
api 'cn.rongcloud.sdk:rtc_lib:5.7.0' //
// 5.1.2
api 'cn.rongcloud.sdk:im_lib:5.7.0'

View File

@ -15,7 +15,6 @@ import com.yunbao.common.R;
import com.yunbao.common.interfaces.ActivityResultCallback;
import com.yunbao.common.utils.ToastUtil;
import cn.rongcloud.rtc.api.RCRTCEngine;
/**
* Created by cxf on 2018/9/29.
@ -117,11 +116,6 @@ public class ProcessFragment extends Fragment {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(null);
}catch (Exception e){
}
if (mActivityResultCallback != null) {
if (resultCode == -1) {//RESULT_OK
mActivityResultCallback.onSuccess(data);

View File

@ -1,270 +0,0 @@
package com.yunbao.common.manager;
import static cn.rongcloud.rtc.base.RTCErrorCode.JOIN_CHAT_ROOM_TIMEOUT;
import android.os.Handler;
import android.os.Looper;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
import cn.rongcloud.rtc.api.RCRTCRoom;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import cn.rongcloud.rtc.base.RTCErrorCode;
/**
* RTC管理类负责管理申请同意拒绝PK
*/
public class IMRTCManager {
private static IMRTCManager manager;
private RCRTCRoom rtcRoom;
private List<String> requestUid;
private IMRTCManager() {
requestUid = new ArrayList<>();
}
public static IMRTCManager getInstance() {
if (manager == null) {
manager = new IMRTCManager();
}
return manager;
}
public void setRtcRoom(RCRTCRoom rtcRoom) {
this.rtcRoom = rtcRoom;
}
/**
* 响应PK请求
*
* @param liveUid 对方房间号
* @param agree 是否同意
* @param extra 扩展参数
* @param callback 回调
*/
public void responseJoinOtherRoom(String liveUid, boolean agree, String extra, IRCRTCResultCallback callback) {
if (rtcRoom != null) {
/*
inviterRoomId - 邀请者所在房间 id
inviterUserId - 邀请者用户 id
agree - 被邀请者是否同意连麦邀请
inviteeAutoMix - 是否将被邀请者音视频资源发送到邀请人房间中合流
1inviteeAutoMix 为true时
1.1如果邀请方在发送连麦请求之前发布了资源当被邀请方加入邀请者房间成功后服务器会把邀请方流资源合并到被邀请方视图默认仅悬浮布局合流
1.2如果邀请方在发送连麦请求之前没有发布资源将会在邀请方发布资源成功后服务器才会把邀请方的资源合并到被邀请方视图默认仅悬浮布局合流
2: 无论为true或false双方都可以使用RCRTCLiveInfo.setMixConfig(RCRTCMixConfig, IRCRTCResultCallback) 方法主动设置合流布局一旦主动设置过合流布局后续音视频直播过程中设置的自动合流参数将失效
extra - 扩展字段默认为空
*/
rtcRoom.getLocalUser().responseJoinOtherRoom(liveUid, liveUid, agree, agree, extra, callback);
} else {
callback.onFailed(RTCErrorCode.RongRTCCodeIMError);
}
}
/**
* 申请PK
*
* @param liveUid 对方房间号
* @param inviterAutoMix 是否将邀请者音视频资源发送到被邀请人房间中合流
* @param extra 扩展参数
* @param callback 回调
*/
public void requestJoinOtherRoom(String liveUid, boolean inviterAutoMix, String extra, IRCRTCResultCallback callback) {
if (requestUid.contains(liveUid)) {
callback.onFailed(RTCErrorCode.RongRTCCodeJoinRepeatedRoom);
return;
}
if (rtcRoom != null && rtcRoom.getLocalUser() != null) {
/*
inviteeRoomId - 被邀请者所在房间 id
inviteeUserId - 被邀请用户 id
inviterAutoMix - 是否将邀请者音视频资源发送到被邀请人房间中合流
1: inviterAutoMix为true时
1.1如果被邀请方在加入邀请方房间之前发布了资源当被邀请方加入邀请者房间成功后服务器会把被邀请方流资源合并到邀请方视图 ·默认仅悬浮布局合流
1.2如果被邀请方在加入邀请方房间之前没有发布过资源将会在被邀请方发布资源成功后服务器会把被邀请方流资源合并到邀请方视图默认仅悬浮布局合流
2:无论为true或false双方都可以使用RCRTCLiveInfo.setMixConfig(RCRTCMixConfig, IRCRTCResultCallback) 方法主动设置合流布局一旦主动设置过合流布局后续音视频直播过程中设置的自动合流参数将失效
extra - 扩展字段默认为空
*/
rtcRoom.getLocalUser().requestJoinOtherRoom(liveUid, liveUid, inviterAutoMix, extra, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
callback.onSuccess();
if (!RandomPkManager.getInstance().isRandomModel()) {
if(WordUtil.isNewZh()) {
ToastUtil.show("发起邀请成功");
}else{
ToastUtil.show("successful");
}
}
requestUid.add(liveUid);
startRequestTimeoutTask(liveUid);
}
@Override
public void onFailed(RTCErrorCode errorCode) {
if (!RandomPkManager.getInstance().isRandomModel()) {
if(WordUtil.isNewZh()) {
ToastUtil.show("邀请失败 " + errorCode.getValue());
}else{
ToastUtil.show("invite failed:" +errorCode.getValue());
}
}
if (RandomPkManager.getInstance().isRequestPk()) {
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
}
requestUid.remove(liveUid);
callback.onFailed(errorCode);
}
});
} else {
callback.onFailed(RTCErrorCode.RongRTCCodeIMError);
}
}
/**
* 注册监听对方通知类还没搞清楚具体用法先搁置
*
* @param listener
*/
public void registerRoomListener(IRCRTCRoomEventsListener listener) {
if (rtcRoom != null && rtcRoom.getLocalUser() != null) {
rtcRoom.registerRoomListener(new IRCRTCRoomEventsListener() {
@Override
public void onRemoteUserPublishResource(RCRTCRemoteUser remoteUser, List<RCRTCInputStream> streams) {
listener.onRemoteUserPublishResource(remoteUser, streams);
}
@Override
public void onRemoteUserMuteAudio(RCRTCRemoteUser remoteUser, RCRTCInputStream stream, boolean mute) {
listener.onRemoteUserMuteAudio(remoteUser, stream, mute);
}
@Override
public void onRemoteUserMuteVideo(RCRTCRemoteUser remoteUser, RCRTCInputStream stream, boolean mute) {
listener.onRemoteUserMuteVideo(remoteUser, stream, mute);
}
@Override
public void onRemoteUserUnpublishResource(RCRTCRemoteUser remoteUser, List<RCRTCInputStream> streams) {
listener.onRemoteUserUnpublishResource(remoteUser, streams);
}
@Override
public void onUserJoined(RCRTCRemoteUser remoteUser) {
listener.onUserJoined(remoteUser);
}
@Override
public void onUserLeft(RCRTCRemoteUser remoteUser) {
listener.onUserLeft(remoteUser);
}
@Override
public void onUserOffline(RCRTCRemoteUser remoteUser) {
listener.onUserOffline(remoteUser);
}
@Override
public void onPublishLiveStreams(List<RCRTCInputStream> streams) {
listener.onPublishLiveStreams(streams);
}
@Override
public void onUnpublishLiveStreams(List<RCRTCInputStream> streams) {
listener.onUnpublishLiveStreams(streams);
}
});
}
}
/**
* 取消邀请
*
* @param liveUid 房间号
* @param extra 扩展参数
* @param callback 回调
*/
public void cancelRequestJoinOtherRoom(String liveUid, String extra, IRCRTCResultCallback callback) {
if (rtcRoom != null && rtcRoom.getLocalUser() != null) {
rtcRoom.getLocalUser().cancelRequestJoinOtherRoom(liveUid, liveUid, extra, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
callback.onSuccess();
}
@Override
public void onFailed(RTCErrorCode errorCode) {
callback.onFailed(errorCode);
}
});
} else {
callback.onFailed(RTCErrorCode.RongRTCCodeIMError);
}
}
public void callPkSuccess(String liveUid) {
requestUid.remove(liveUid);
}
private void startRequestTimeoutTask(String liveUid) {
new Timer().schedule(new TimerTask() {
int waitTime = 15;
@Override
public void run() {
if (!requestUid.contains(liveUid)) {
cancel();
return;
}
if (waitTime-- == 0) {
//callback.onFailed(JOIN_CHAT_ROOM_TIMEOUT);
cancelRequestJoinOtherRoom(liveUid, "extra", new IRCRTCResultCallback() {
@Override
public void onSuccess() {
requestUid.remove(liveUid);
if (RandomPkManager.getInstance().isRandomModel()) {
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
requestUid.remove(liveUid);
if (RandomPkManager.getInstance().isRandomModel()) {
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
}
}
});
cancel();
}
}
}, 1000, 1000);
}
public void leaveOtherRoom(String roomId,
boolean notifyFinished,
IRCRTCResultCallback callBack) {
RCRTCEngine.getInstance().leaveOtherRoom(roomId, notifyFinished, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
callBack.onSuccess();
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
callBack.onFailed(rtcErrorCode);
}
});
}
}

View File

@ -1,559 +0,0 @@
package com.yunbao.common.manager.imrongcloud;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.SudGameChatImModel;
import com.yunbao.common.bean.SudGameUserModel;
import com.yunbao.common.event.SudGameSocketImEvent;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import java.util.ArrayList;
import java.util.List;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
import cn.rongcloud.rtc.api.RCRTCRoom;
import cn.rongcloud.rtc.api.RCRTCRoomConfig;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import cn.rongcloud.rtc.base.RCRTCParamsType;
import cn.rongcloud.rtc.base.RCRTCRoomType;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.chatroom.base.RongChatRoomClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.message.TextMessage;
public class GameRyMicManager {
MeetingCallback mMeetingCallback = null;
private RCRTCRoom mRtcRoom = null;
private String mRoomID = "";
private final IRCRTCRoomEventsListener roomEventsListener = new IRCRTCRoomEventsListener() {
/**
* 房间内用户发布资源
*
* @param rcrtcRemoteUser 远端用户
* @param list 发布的资源
*/
@Override
public void onRemoteUserPublishResource(RCRTCRemoteUser rcrtcRemoteUser, final List<RCRTCInputStream> list) {
// subscribeAVStream();
}
@Override
public void onRemoteUserMuteAudio(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
}
@Override
public void onRemoteUserMuteVideo(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
}
@Override
public void onRemoteUserUnpublishResource(RCRTCRemoteUser rcrtcRemoteUser, List<RCRTCInputStream> list) {
}
/**
* 用户加入房间
*
* @param rcrtcRemoteUser 远端用户
*/
@Override
public void onUserJoined(final RCRTCRemoteUser rcrtcRemoteUser) {
try {
getView().onUserJoined(rcrtcRemoteUser);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
/**
* 用户离开房间
*
* @param rcrtcRemoteUser 远端用户
*/
@Override
public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
try {
getView().onUserLeft(rcrtcRemoteUser);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onUserOffline(RCRTCRemoteUser rcrtcRemoteUser) {
}
@Override
public void onPublishLiveStreams(List<RCRTCInputStream> list) {
}
@Override
public void onUnpublishLiveStreams(List<RCRTCInputStream> list) {
}
/**
* 自己退出房间 例如断网退出等
* @param i 状态码
*/
@Override
public void onLeaveRoom(int i) {
}
};
protected MeetingCallback getView() {
if (mMeetingCallback == null) {
throw new IllegalStateException("view is not attached");
} else {
return mMeetingCallback;
}
}
public void attachView(MeetingCallback callback) {
mMeetingCallback = callback;
}
public void detachView() {
mMeetingCallback = null;
}
/**
* 主动订阅远端用户发布的流
* 视频流需要用户设置用于显示载体的videoview
*/
public void subscribeAVStream() {
if (mRtcRoom == null || mRtcRoom.getRemoteUsers() == null) {
return;
}
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
for (final RCRTCRemoteUser remoteUser : mRtcRoom.getRemoteUsers()) {
if (remoteUser.getStreams().size() == 0) {
continue;
}
inputStreams.addAll(remoteUser.getStreams());
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(inputStreams);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onSubscribeFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
public void refreshStreams(List<SudGameUserModel> personList) {
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
for (SudGameUserModel sudGameUserModel : personList) {
List<RCRTCRemoteUser> rcrtcRemoteUsers = mRtcRoom.getRemoteUsers();
for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) {
if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(sudGameUserModel.getId()))) {
for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) {
rcrtcInputStream.mute(sudGameUserModel.getMicStatus() == 3);
}
inputStreams.addAll(rcrtcRemoteUser.getStreams());
}
}
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(inputStreams);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onSubscribeFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
public void refreshStreams(String userID, boolean mute, int position) {
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
List<RCRTCRemoteUser> rcrtcRemoteUsers = mRtcRoom.getRemoteUsers();
for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) {
if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(userID))) {
for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) {
rcrtcInputStream.mute(mute);
}
inputStreams.addAll(rcrtcRemoteUser.getStreams());
}
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(userID, mute, position);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onSubscribeFailed(userID);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
public void unPublishStreams() {
if (mRtcRoom == null) {
return;
}
mRtcRoom.getLocalUser().unpublishStream(RCRTCEngine.getInstance().getDefaultAudioStream(), new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onUnPublishStreamsSuccess();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onUnPublishStreamsFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
/**
* 发布默认流
*/
public void publishDefaultAVStream() {
if (mRtcRoom == null) {
return;
}
mRtcRoom.getLocalUser().publishStream(RCRTCEngine.getInstance().getDefaultAudioStream(), new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onPublishSuccess();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
try {
getView().onPublishFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
/**
* 配置rtc sdk
*/
public void config(Context context) {
// RCRTCConfig.Builder configBuilder = RCRTCConfig.Builder.create();
// // 是否硬解码
// configBuilder.enableHardwareDecoder(true);
// // 是否硬编码
// configBuilder.enableHardwareEncoder(true);
//
// // init 需结合 uninit 使用否则有些配置无法重新初始化
// RCRTCEngine.getInstance().unInit();
// RCRTCEngine.getInstance().init(context, configBuilder.build());
// RCRTCVideoStreamConfig.Builder videoConfigBuilder = RCRTCVideoStreamConfig.Builder.create();
// // 设置分辨率
// videoConfigBuilder.setVideoResolution(RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280);
// // 设置帧率
// videoConfigBuilder.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_30);
// /**
// * 设置最小码率可根据分辨率RCRTCVideoResolution设置
// * {@link RCRTCParamsType.RCRTCVideoResolution)}
// */
// videoConfigBuilder.setMinRate(250);
// /**
// * 设置最大码率可根据分辨率RCRTCVideoResolution设置
// * {@link RCRTCParamsType.RCRTCVideoResolution)}
// */
// videoConfigBuilder.setMaxRate(2200);
// RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(videoConfigBuilder.build());
//打开扬声器
RCRTCEngine.getInstance().enableSpeaker(true);
// 启用耳返功能
RCRTCEngine.getInstance().getDefaultAudioStream().enableEarMonitoring(true);
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(false);
RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC_HIGH, RCRTCParamsType.AudioScenario.MUSIC_CHATROOM);
}
public void joinRoom(String roomId, boolean imOff) {
mRoomID = roomId;
if (imOff) {
RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
// 根据实际场景选择音视频直播LIVE_AUDIO_VIDEO 或音频直播LIVE_AUDIO
.setRoomType(RCRTCRoomType.MEETING)
.build();
RCRTCEngine.getInstance().joinRoom("v" + roomId, roomConfig, new IRCRTCResultDataCallback<RCRTCRoom>() {
@Override
public void onSuccess(final RCRTCRoom rcrtcRoom) {
GameRyMicManager.this.mRtcRoom = rcrtcRoom;
// 注册房间回调
rcrtcRoom.registerRoomListener(roomEventsListener);
try {
getView().onJoinRoomSuccess(rcrtcRoom);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
try {
getView().onJoinRoomFailed(rtcErrorCode);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
RongChatRoomClient.getInstance().joinChatRoom("v" + roomId, -1, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
Log.i("tx", "加入成功");
enterRoom();
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
Log.i("tx", "加入" + "失败" + coreErrorCode);
if (WordUtil.isNewZh()) {
ToastUtil.show("網絡不佳無法連接,請重新進入");
} else {
ToastUtil.show("The network is not connected, please re-enter");
}
}
});
}
public void leaveRoom() {
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
}
@Override
public void onSuccess() {
}
});
RongChatRoomClient.getInstance().quitChatRoom("v" + mRoomID, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
Log.i("tx", "退出成功");
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
Log.i("tx", "退出" + "" + coreErrorCode);
}
});
}
/**
* 处理游戏房Im消息
*/
public void processingMessage(SudGameSocketImEvent socketImModel) {
List<SudGameSocketImEvent.MsgDTO> msgDTOS = socketImModel.getMsg();
if (msgDTOS.isEmpty()) return;
SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0);
//正常文字消息
if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) {
getView().insertItem(new SudGameChatImModel().setWelcomMessage(false).setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt()));
} else if (TextUtils.equals(msgDTO.getMethod(), "welcomMessage")) {
// 欢迎用户名进入房间 Welcome (username) to the room
StringBuffer stringBuffer = new StringBuffer();
if (WordUtil.isNewZh()) {
stringBuffer.append("歡迎 ").append(msgDTO.getCt()).append(" 進入房間");
} else {
stringBuffer.append("Welcome ").append(msgDTO.getCt()).append(" to enter the room");
}
getView().insertItem(new SudGameChatImModel().setWelcomMessage(true).setNickname(msgDTO.getCt()).setTextMessage(stringBuffer.toString()));
} else if (TextUtils.equals(msgDTO.getMethod(), "sudGameRoomVoiceList")) {
List<SudGameUserModel> personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken<List<SudGameUserModel>>() {
}.getType());
getView().refreshSudGameUserList(personList);
refreshStreams(personList);
}
}
private void sendChatMessage(String textMessage, String method) {
IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
SudGameSocketImEvent sudGameSocketImEvent = new SudGameSocketImEvent();
sudGameSocketImEvent.setRetcode("000000");
sudGameSocketImEvent.setRetmsg("ok");
SudGameSocketImEvent.MsgDTO msgDTO = new SudGameSocketImEvent.MsgDTO();
msgDTO.setAction("0")
.setCt(textMessage)
.setEquipment("app")
.setUid(String.valueOf(loginModel.getId()))
.setMethod(method)
.setUname(loginModel.getUserNicename())
.setRoomnum(mRoomID);
List<SudGameSocketImEvent.MsgDTO> msgDTOS = new ArrayList<>();
msgDTOS.add(msgDTO);
sudGameSocketImEvent.setMsg(msgDTOS);
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(new Gson().toJson(sudGameSocketImEvent));
Message message = Message.obtain("v" + mRoomID, conversationType, messageContent);
RongcloudIMManager.sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
processingMessage(sudGameSocketImEvent);
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
Log.i("tx", "发送成功" + errorCode.toString());
}
});
}
/**
* 发送聊天信息
*
* @param textMessage
*/
public void sendMessage(String textMessage) {
sendChatMessage(textMessage, "SendMsg");
}
/**
* 进房间
*/
public void enterRoom() {
IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
sendChatMessage(loginModel.getUserNicename(), "welcomMessage");
}
/**
* activity相关回调
*/
public interface MeetingCallback {
void onJoinRoomSuccess(RCRTCRoom rcrtcRoom);
void onJoinRoomFailed(RTCErrorCode rtcErrorCode);
void onPublishSuccess();
void onPublishFailed();
void onUnPublishStreamsSuccess();
void onUnPublishStreamsFailed();
void onSubscribeSuccess(List<RCRTCInputStream> inputStreamList);
void onSubscribeFailed();
void onSubscribeSuccess(String userID, boolean mute, int position);
void onSubscribeFailed(String userID);
void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser);
void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser);
void insertItem(SudGameChatImModel sudGameChatImModel);
void refreshSudGameUserList(List<SudGameUserModel> personList);
}
}

View File

@ -1,127 +1,30 @@
package com.yunbao.common.manager.imrongcloud;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.SudGameChatImModel;
import com.yunbao.common.bean.SudGameUserModel;
import com.yunbao.common.event.SudGameSocketImEvent;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import java.util.ArrayList;
import java.util.List;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
import cn.rongcloud.rtc.api.RCRTCRoom;
import cn.rongcloud.rtc.api.RCRTCRoomConfig;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import cn.rongcloud.rtc.base.RCRTCParamsType;
import cn.rongcloud.rtc.base.RCRTCRoomType;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.chatroom.base.RongChatRoomClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.message.TextMessage;
public class GameSwMicManager {
MeetingCallback mMeetingCallback = null;
private RCRTCRoom mRtcRoom = null;
private String mRoomID = "";
public void setmRoomID(String mRoomID) {
this.mRoomID = mRoomID;
}
private final IRCRTCRoomEventsListener roomEventsListener = new IRCRTCRoomEventsListener() {
/**
* 房间内用户发布资源
*
* @param rcrtcRemoteUser 远端用户
* @param list 发布的资源
*/
@Override
public void onRemoteUserPublishResource(RCRTCRemoteUser rcrtcRemoteUser, final List<RCRTCInputStream> list) {
// subscribeAVStream();
}
@Override
public void onRemoteUserMuteAudio(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
}
@Override
public void onRemoteUserMuteVideo(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
}
@Override
public void onRemoteUserUnpublishResource(RCRTCRemoteUser rcrtcRemoteUser, List<RCRTCInputStream> list) {
}
/**
* 用户加入房间
*
* @param rcrtcRemoteUser 远端用户
*/
@Override
public void onUserJoined(final RCRTCRemoteUser rcrtcRemoteUser) {
try {
getView().onUserJoined(rcrtcRemoteUser);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
/**
* 用户离开房间
*
* @param rcrtcRemoteUser 远端用户
*/
@Override
public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
try {
getView().onUserLeft(rcrtcRemoteUser);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onUserOffline(RCRTCRemoteUser rcrtcRemoteUser) {
}
@Override
public void onPublishLiveStreams(List<RCRTCInputStream> list) {
}
@Override
public void onUnpublishLiveStreams(List<RCRTCInputStream> list) {
}
/**
* 自己退出房间 例如断网退出等
* @param i 状态码
*/
@Override
public void onLeaveRoom(int i) {
}
};
protected MeetingCallback getView() {
if (mMeetingCallback == null) {
throw new IllegalStateException("view is not attached");
@ -138,336 +41,6 @@ public class GameSwMicManager {
mMeetingCallback = null;
}
/**
* 主动订阅远端用户发布的流
* 视频流需要用户设置用于显示载体的videoview
*/
public void subscribeAVStream() {
if (mRtcRoom == null || mRtcRoom.getRemoteUsers() == null) {
return;
}
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
for (final RCRTCRemoteUser remoteUser : mRtcRoom.getRemoteUsers()) {
if (remoteUser.getStreams().size() == 0) {
continue;
}
inputStreams.addAll(remoteUser.getStreams());
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(inputStreams);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onSubscribeFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
public void refreshStreams(List<SudGameUserModel> personList) {
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
if(mRtcRoom!=null){
for (SudGameUserModel sudGameUserModel : personList) {
List<RCRTCRemoteUser> rcrtcRemoteUsers = mRtcRoom.getRemoteUsers();
for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) {
if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(sudGameUserModel.getId()))) {
for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) {
rcrtcInputStream.mute(sudGameUserModel.getMicStatus() == 3);
}
inputStreams.addAll(rcrtcRemoteUser.getStreams());
}
}
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(inputStreams);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onSubscribeFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
}
public void refreshStreams(String userID, boolean mute, int position) {
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
List<RCRTCRemoteUser> rcrtcRemoteUsers = mRtcRoom.getRemoteUsers();
for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) {
if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(userID))) {
for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) {
rcrtcInputStream.mute(mute);
}
inputStreams.addAll(rcrtcRemoteUser.getStreams());
}
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(userID, mute, position);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onSubscribeFailed(userID);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
public void unPublishStreams() {
if (mRtcRoom == null) {
return;
}
mRtcRoom.getLocalUser().unpublishStream(RCRTCEngine.getInstance().getDefaultAudioStream(), new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onUnPublishStreamsSuccess();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onUnPublishStreamsFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
/**
* 发布默认流
*/
public void publishDefaultAVStream() {
if (mRtcRoom == null) {
return;
}
mRtcRoom.getLocalUser().publishStream(RCRTCEngine.getInstance().getDefaultAudioStream(), new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onPublishSuccess();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
try {
getView().onPublishFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
/**
* 配置rtc sdk
*/
public void config(Context context) {
// RCRTCConfig.Builder configBuilder = RCRTCConfig.Builder.create();
// // 是否硬解码
// configBuilder.enableHardwareDecoder(true);
// // 是否硬编码
// configBuilder.enableHardwareEncoder(true);
//
// // init 需结合 uninit 使用否则有些配置无法重新初始化
// RCRTCEngine.getInstance().unInit();
// RCRTCEngine.getInstance().init(context, configBuilder.build());
// RCRTCVideoStreamConfig.Builder videoConfigBuilder = RCRTCVideoStreamConfig.Builder.create();
// // 设置分辨率
// videoConfigBuilder.setVideoResolution(RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280);
// // 设置帧率
// videoConfigBuilder.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_30);
// /**
// * 设置最小码率可根据分辨率RCRTCVideoResolution设置
// * {@link RCRTCParamsType.RCRTCVideoResolution)}
// */
// videoConfigBuilder.setMinRate(250);
// /**
// * 设置最大码率可根据分辨率RCRTCVideoResolution设置
// * {@link RCRTCParamsType.RCRTCVideoResolution)}
// */
// videoConfigBuilder.setMaxRate(2200);
// RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(videoConfigBuilder.build());
//打开扬声器
RCRTCEngine.getInstance().enableSpeaker(true);
// 启用耳返功能
RCRTCEngine.getInstance().getDefaultAudioStream().enableEarMonitoring(true);
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(false);
RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC_HIGH, RCRTCParamsType.AudioScenario.MUSIC_CHATROOM);
}
public void joinRoom(String roomId, boolean imOff) {
mRoomID = roomId;
if (imOff) {
RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
// 根据实际场景选择音视频直播LIVE_AUDIO_VIDEO 或音频直播LIVE_AUDIO
.setRoomType(RCRTCRoomType.MEETING)
.build();
RCRTCEngine.getInstance().joinRoom("v" + roomId, roomConfig, new IRCRTCResultDataCallback<RCRTCRoom>() {
@Override
public void onSuccess(final RCRTCRoom rcrtcRoom) {
GameSwMicManager.this.mRtcRoom = rcrtcRoom;
// 注册房间回调
rcrtcRoom.registerRoomListener(roomEventsListener);
try {
getView().onJoinRoomSuccess(rcrtcRoom);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
try {
getView().onJoinRoomFailed(rtcErrorCode);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
RongChatRoomClient.getInstance().joinChatRoom("v" + roomId, -1, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
Log.i("tx", "加入成功");
enterRoom();
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
Log.i("tx", "加入" + "失败" + coreErrorCode);
if (WordUtil.isNewZh()) {
ToastUtil.show("網絡不佳無法連接,請重新進入");
} else {
ToastUtil.show("The network is not connected, please re-enter");
}
}
});
}
public void leaveRoom() {
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
}
@Override
public void onSuccess() {
}
});
RongChatRoomClient.getInstance().quitChatRoom("v" + mRoomID, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
Log.i("tx", "退出成功");
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
Log.i("tx", "退出" + "" + coreErrorCode);
}
});
}
/**
* 处理游戏房Im消息
*/
public void processingMessage(SudGameSocketImEvent socketImModel) {
List<SudGameSocketImEvent.MsgDTO> msgDTOS = socketImModel.getMsg();
if (msgDTOS.isEmpty()) return;
SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0);
//正常文字消息
if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) {
getView().insertItem(new SudGameChatImModel().setWelcomMessage(false).setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt()));
} else if (TextUtils.equals(msgDTO.getMethod(), "welcomMessage")) {
// 欢迎用户名进入房间 Welcome (username) to the room
StringBuffer stringBuffer = new StringBuffer();
if (WordUtil.isNewZh()) {
stringBuffer.append("歡迎 ").append(msgDTO.getCt()).append(" 進入房間");
} else {
stringBuffer.append("Welcome ").append(msgDTO.getCt()).append(" to enter the room");
}
getView().insertItem(new SudGameChatImModel().setWelcomMessage(true).setNickname(msgDTO.getCt()).setTextMessage(stringBuffer.toString()));
} else if (TextUtils.equals(msgDTO.getMethod(), "sudGameRoomVoiceList")) {
List<SudGameUserModel> personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken<List<SudGameUserModel>>() {
}.getType());
getView().refreshSudGameUserList(personList);
refreshStreams(personList);
}
}
private void sendChatMessage(String textMessage, String method) {
IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
SudGameSocketImEvent sudGameSocketImEvent = new SudGameSocketImEvent();
@ -502,7 +75,6 @@ public class GameSwMicManager {
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
sudGameSocketImEvent.getMsg().get(0).setTime("11");
processingMessage(sudGameSocketImEvent);
}
@Override
@ -533,33 +105,12 @@ public class GameSwMicManager {
* activity相关回调
*/
public interface MeetingCallback {
void onJoinRoomSuccess(RCRTCRoom rcrtcRoom);
void onJoinRoomFailed(RTCErrorCode rtcErrorCode);
void onPublishSuccess();
void onPublishFailed();
void onUnPublishStreamsSuccess();
void onUnPublishStreamsFailed();
void onSubscribeSuccess(List<RCRTCInputStream> inputStreamList);
void onSubscribeFailed();
void onSubscribeSuccess(String userID, boolean mute, int position);
void onSubscribeFailed(String userID);
void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser);
void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser);
void insertItem(SudGameChatImModel sudGameChatImModel);
void refreshSudGameUserList(List<SudGameUserModel> personList);
}
}

View File

@ -16,10 +16,6 @@ import com.yunbao.common.http.ResponseModel;
import java.util.ArrayList;
import java.util.List;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
@ -100,71 +96,6 @@ public class MicStatusManager {
'}';
}
/**
* 断开连麦
*/
public void downMic() {
HttpClient.getInstance().get("live.leaveDrLm", "live.leaveDrLm")
.params("roomid", micLiveId)
.params("uid", CommonAppConfig.getInstance().getUid())
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.e("ry", code + "退出多人");
RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() {
/**
* 当切换失败且SDK处于无法回退状态时回调该角色已经无法使用当前角色继续进行音视频
* SDK内部会退出房间并清理所有资源该用户只能重新加入房间才能继续音视频
*/
@Override
public void onKicked() {
}
@Override
public void onSuccess() {
Log.e("ry", "下麦成功");
// 该用户切换为观众成功可以以观众身份进行音视频
//退出rtc播放
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.e("ry", "退出多人房间成功");
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
MicStatusManager.getInstance().clear();
if(WordUtil.isNewZh()) {
ToastUtil.show("已成功退出語音連麥");
}else{
ToastUtil.show("You have successfully exited the voice connection");
}
}
});
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", errorCode + "退出多人房间成功");
}
});
}
/**
* 当切换失败且不影响当前角色继续音视频时回调
* @param errorCode 失败错误码
*/
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "下麦失败" + errorCode);
}
});
}
});
}
/**
* 主播关闭连麦权限

View File

@ -82,12 +82,10 @@ import com.yunbao.live.dialog.LiveUserMoreDialogFragment;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPkPresenter;
import com.yunbao.live.presenter.LiveLinkMicPresenter;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
import com.yunbao.live.presenter.LiveSwLinkMicPkPresenter;
import com.yunbao.live.socket.SocketClient;
import com.yunbao.live.socket.SocketMessageListener;
import com.yunbao.live.socket.SocketRyChatUtil;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSwChatUtil;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.utils.LoadDian9TuUtil;
@ -129,13 +127,13 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
protected LiveLinkMicPresenter mLiveLinkMicPresenter;//观众与主播连麦逻辑
protected LiveLinkMicAnchorPresenter mLiveLinkMicAnchorPresenter;//主播与主播连麦逻辑
protected LiveLinkMicPkPresenter mLiveLinkMicPkPresenter;//主播与主播PK逻辑 腾讯
public static LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;//主播与主播PK逻辑 融云
// public static LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;//主播与主播PK逻辑 融云
public static LiveSwLinkMicPkPresenter mLiveSwLinkMicPkPresenter;//主播与主播PK逻辑 声网
public SocketClient mSocketClient;
public SocketSwClient mSocketSwClient;
public SocketRyClient mSocketRyClient;
// public SocketRyClient mSocketRyClient;
protected LiveBean mLiveBean;
protected int mLiveSDK;//sdk类型 0金山 1腾讯
@ -412,9 +410,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
@Override
public void onSendGiftPk(long leftGift, long rightGift, LivePKUserListBean bean) {
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
}
if (mLiveSwLinkMicPkPresenter != null) {
mLiveSwLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
}
@ -422,14 +417,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
@Override
public void onEndPk(long leftUid, long rightUid, long left, long right, LivePKUserListBean bean) {
if (mLiveRyLinkMicPkPresenter != null) {
L.eSw("onEndPk 结束PK mLiveRyLinkMicPkPresenter");
if (mLiveUid.equals(leftUid + "")) {
mLiveRyLinkMicPkPresenter.onPkProgressEnd(left, right, bean);
} else {
mLiveRyLinkMicPkPresenter.onPkProgressEnd(right, left, bean);
}
}
if (mLiveSwLinkMicPkPresenter != null) {
L.eSw("onEndPk 结束PK mLiveSwLinkMicPkPresenter");
if (mLiveUid.equals(leftUid + "")) {
@ -699,9 +686,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
if (mLiveLinkMicAnchorPresenter != null) {
mLiveLinkMicAnchorPresenter.onLinkMicAnchorClose();
}
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkClose(1);
}
if (mLiveSwLinkMicPkPresenter != null) {
mLiveSwLinkMicPkPresenter.onLinkMicPkClose(1);
@ -774,13 +758,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
mLiveRoomViewHolder.initAnchorSay();
mLiveRoomViewHolder.closePrankView();
}
} else {
if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
pr = new pkRunnable(pkUid, pkhead, pkname, isLadders);
mHandler.postDelayed(pr, 4000);//3秒后执行Runnable中的run方法
mLiveRoomViewHolder.closePrankView();
}
}
}
@ -817,9 +794,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
*/
@Override
public void onLinkMicPkClose(int i) {
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkClose(i);
} else if (mLiveLinkMicPkPresenter != null) {
if (mLiveLinkMicPkPresenter != null) {
mLiveLinkMicPkPresenter.onLinkMicPkClose(i);
} else if (mLiveSwLinkMicPkPresenter != null) {
mLiveSwLinkMicPkPresenter.onLinkMicPkClose(i);
@ -855,10 +830,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
*/
@Override
public void onLinkMicPkEnd(String winUid) {
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkEnd(winUid);
mLiveRoomViewHolder.setDelOtherInfo();
} else if (mLiveLinkMicPkPresenter != null) {
if (mLiveLinkMicPkPresenter != null) {
mLiveLinkMicPkPresenter.onLinkMicPkEnd(winUid);
mLiveRoomViewHolder.setDelOtherInfo();
} else if (mLiveSwLinkMicPkPresenter != null) {
@ -1060,8 +1032,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE;
if(isSw){
SocketSwChatUtil.sendChatMessage(mLiveUid, content, IMLoginManager.get(mContext).getUserInfo().anchorUserType(), mSocketUserType, guardType, atUserID, atUserName);
}else{
SocketRyChatUtil.sendChatMessage(mLiveUid, content, IMLoginManager.get(mContext).getUserInfo().anchorUserType(), mSocketUserType, guardType, atUserID, atUserName);
}
}
@ -1812,8 +1782,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
fragment.setAudienceList(mAudienceList);
if(isSw){
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
}else{
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
}
}

View File

@ -517,9 +517,6 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
mLiveLinkMicPkPresenter.setLiveUid(mLiveUid, mUrl);
mLiveLinkMicPkPresenter.setSelfStream(mStream);
}
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.setLiveUid(mLiveUid, "");
}
//开始推流
@ -635,9 +632,6 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
if (mSocketSwClient != null) {
mSocketSwClient.disConnect();
}
if (mSocketRyClient != null) {
mSocketRyClient.disConnect();
}
}
if (mLiveEndViewHolder == null) {
mLiveEndViewHolder = new LiveEndViewHolder(mContext, mRoot, mLiveBean.getUid());

View File

@ -124,10 +124,6 @@ import java.io.File;
import java.util.List;
import java.util.Random;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.base.RCRTCRect;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.SWManager;
import io.agora.rtc2.RtcEngine;
import io.rong.imlib.IRongCallback;
@ -559,7 +555,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
if (PKing || isDRPK == 1) {
return;
}
RCRTCRect rect = new RCRTCRect(0f, 0f, 1.0f);
// RCRTCRect rect = new RCRTCRect(0f, 0f, 1.0f);
if (leave == 0) {
leave = 1;
leave_img.setVisibility(View.VISIBLE);
@ -567,7 +563,6 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(BitmapUtil.getInstance().convertMirror(resource), rect);
sendSystemMessageSw(mContext.getString(R.string.live_anchor_leave));
}
@ -582,7 +577,6 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
leave = 0;
leave_img.setVisibility(View.GONE);
// 清除水印
boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(null, rect);
sendSystemMessageSw(mContext.getString(R.string.live_anchor_come_back));
SWManager.get().setLeaveFlag(false);
mLiveAnchorViewHolder.setLeaveFlag(false);
@ -926,31 +920,6 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
}
public void endLives() {
RCRTCEngine.getInstance().getDefaultVideoStream().stopCamera(new IRCRTCResultCallback() {
@Override
public void onSuccess() {
}
@Override
public void onFailed(RTCErrorCode errorCode) {
}
});
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
@Override
public void onSuccess() {
Log.i("ry", "退出成功");
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.i("ry", "退出失败" + errorCode);
}
});
if (mLivePushViewHolder != null) {
mLivePushViewHolder.release();
}

View File

@ -1,765 +0,0 @@
package com.yunbao.live.activity;
import android.Manifest;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.lzf.easyfloat.EasyFloat;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.R;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.adapter.SudGameChatAdapter;
import com.yunbao.common.adapter.SudGameUserListAdapter;
import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.CustomSidebarChildModel;
import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.RoomMicStatusModel;
import com.yunbao.common.bean.SudGameChatImModel;
import com.yunbao.common.bean.SudGameInfoBean;
import com.yunbao.common.bean.SudGameScoreBean;
import com.yunbao.common.bean.SudGameUserModel;
import com.yunbao.common.dialog.SudGameDoubleDialog;
import com.yunbao.common.dialog.SudGameMultipleDialog;
import com.yunbao.common.dialog.SudGameInputPopupWindow;
import com.yunbao.common.dialog.SudLoadDialog;
import com.yunbao.common.event.CheckRemainingBalanceEvent;
import com.yunbao.common.event.SubGameEvent;
import com.yunbao.common.event.SudGameSocketImEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.imrongcloud.GameRyMicManager;
import com.yunbao.common.sud.QuickStartGameViewModel;
import com.yunbao.common.sud.model.GameConfigModel;
import com.yunbao.common.sud.model.GameViewInfoModel;
import com.yunbao.common.sud.state.SudMGPAPPState;
import com.yunbao.common.sud.state.SudMGPMGState;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ProcessResultUtil;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.LiveSudGameHistoryPopup;
import com.yunbao.common.views.TopGradual;
import com.yunbao.common.views.floatingview.APPEasyFloat;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.dialog.LiveUserDialogFragment;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
import cn.rongcloud.rtc.api.RCRTCRoom;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import cn.rongcloud.rtc.base.RTCErrorCode;
@Route(path = RouteUtil.PATH_SudRyGameActivity)
public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.MeetingCallback {
private FrameLayout gameContainer;
private long mInteractionID;
private String mLiveUid;
private final QuickStartGameViewModel gameViewModel = new QuickStartGameViewModel(); // 创建ViewModel
private CreateSudRoomModel mCreateSudRoomModel;
private TextView roomName, roomNumber;
private GameRyMicManager gameMicManager;
private ImageView gameCloseWheat, gameSeat;
private boolean disable = true, publishDefault = false;
private RecyclerView chatList, userList;
private SudGameChatAdapter mLiveChatAdapter;
private SudGameUserListAdapter sudGameUserListAdapter;
private ProcessResultUtil mProcessResultUtil;
private List<String> muteUser = new ArrayList<>();
private boolean imOff;
private SudGameDoubleDialog sudGameDoubleDialog;//双人游戏弹窗
private SudGameMultipleDialog sudGameMultipleDialog;//多人游戏弹窗
private SudLoadDialog sudLoadDialog;//加载弹窗
@Override
protected int getLayoutId() {
return R.layout.activity_sud_game;
}
@Override
protected void main() {
Bus.getOn(this);
super.main();
initView();
//进游戏房就关掉小窗
EasyFloat.dismiss("LiveFloatView", true);
APPEasyFloat.getInstance().dismiss(mContext);
initDate();
}
private List<CustomSidebarChildModel> customSidebarChildModels = new ArrayList<>();
private void initDate() {
CommonAppConfig.getInstance().getConfig().isSw();
LiveNetManager.get(mContext)
.getCustomSidebarInfo("1", new HttpCallback<List<CustomSidebarInfoModel>>() {
@Override
public void onSuccess(List<CustomSidebarInfoModel> data) {
for (CustomSidebarInfoModel datum : data) {
if (datum.getType().equals("6")) {
customSidebarChildModels = datum.getChild();
return;
}
}
}
@Override
public void onError(String error) {
}
});
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
gameCloseWheat.setVisibility(View.INVISIBLE);
mProcessResultUtil = new ProcessResultUtil(this);
LiveNetManager.get(mContext)
.getRoomMicStatus(new HttpCallback<RoomMicStatusModel>() {
@Override
public void onSuccess(RoomMicStatusModel data) {
gameMicManager = new GameRyMicManager();
gameMicManager.attachView(SudRyGameActivity.this);
gameMicManager.config(SudRyGameActivity.this);
//语音
if (TextUtils.equals(data.getMicStatus(), "1")) {
imOff = true;
gameSeat.setVisibility(View.VISIBLE);
userList.setVisibility(View.VISIBLE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
ToastUtil.show("拒绝权限将无法使用上麦功能");
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
@Override
public void run() {
}
});
}
}
}, 1500);
} else {
imOff = false;
gameSeat.setVisibility(View.GONE);
userList.setVisibility(View.GONE);
}
if (TextUtils.equals(data.getImStatus(), "1")) {
findViewById(R.id.game_review_input).setVisibility(View.VISIBLE);
chatList.setVisibility(View.VISIBLE);
} else {
findViewById(R.id.game_review_input).setVisibility(View.GONE);
chatList.setVisibility(View.GONE);
}
gameMicManager.joinRoom(mLiveUid, imOff);
}
@Override
public void onError(String error) {
imOff = false;
//文字
findViewById(R.id.game_review_input).setVisibility(View.GONE);
chatList.setVisibility(View.GONE);
//语音
gameCloseWheat.setVisibility(View.GONE);
gameSeat.setVisibility(View.GONE);
userList.setVisibility(View.GONE);
}
});
}
@Override
protected void onDestroy() {
LiveNetManager.get(mContext)
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
if (gameMicManager != null) {
gameMicManager.leaveRoom();
gameMicManager.detachView();
}
Bus.getOff(this);
super.onDestroy();
}
private void initView() {
String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom");
mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class);
mInteractionID = mCreateSudRoomModel.getLongSudGameId();
mLiveUid = mCreateSudRoomModel.getSudGameRoomId();
//第二次进入时viewmodel数据丢失所以初始化时直接获取
gameViewModel.getScore(mCreateSudRoomModel.getSudGameRoomId(),mContext);
gameContainer = findViewById(R.id.game_container);
roomName = findViewById(R.id.room_name);
roomNumber = findViewById(R.id.room_number);
gameCloseWheat = findViewById(R.id.game_close_wheat);
gameSeat = findViewById(R.id.game_seat);
chatList = findViewById(R.id.chat_list);
userList = findViewById(R.id.user_list);
//聊天栏
FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams)
chatList.getLayoutParams();
params1.topMargin = DpUtil.dp2px(65);
chatList.setLayoutParams(params1);
chatList.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
layoutManager.setOrientation(RecyclerView.VERTICAL);
layoutManager.setStackFromEnd(true);
chatList.setLayoutManager(layoutManager);
chatList.addItemDecoration(new TopGradual());
chatList.setItemViewCacheSize(10);
mLiveChatAdapter = new SudGameChatAdapter(mContext);
chatList.setAdapter(mLiveChatAdapter);
sudGameUserListAdapter = new SudGameUserListAdapter(new ArrayList<>());
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
sudGameUserListAdapter.setSudGameSmallCallBack(new SudGameUserListAdapter.SudGameSmallCallBack() {
@Override
public void unMute(String userID, int position) {
if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
gameMicManager.refreshStreams(userID, false, position);
} else {
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
}
muteUser.remove(userID);
}
@Override
public void mute(String userID, int position) {
muteUser.add(userID);
if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
gameMicManager.refreshStreams(userID, true, position);
} else {
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
}
}
@Override
public void viewInformation(SudGameUserModel sudGameUserModel) {
LiveUserDialogFragment fragment = new LiveUserDialogFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.LIVE_UID, "uid");
bundle.putString(Constants.STREAM, "");
bundle.putString(Constants.TO_UID, sudGameUserModel.getId() + "");
fragment.setArguments(bundle);
fragment.show(((SudRyGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
}
});
userList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
userList.setAdapter(sudGameUserListAdapter);
if (mCreateSudRoomModel != null) {
roomName.setText(mCreateSudRoomModel.getRoomName());
roomNumber.setText(mCreateSudRoomModel.getSudGameRoomId());
}
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.exit), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
gameViewModel.onDestroy();
finish();
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_history), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
new XPopup.Builder(mContext)
.enableDrag(false)
.asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show();
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_seat), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (imOff && gameMicManager != null) {
if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
if (publishDefault) {
disable = true;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
// ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
gameMicManager.unPublishStreams();
} else {
if (sudGameUserListAdapter.isMicMax()) {
ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
} else {
gameMicManager.publishDefaultAVStream();
}
}
} else {
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
@Override
public void run() {
}
});
}
}
}
});
ViewClicksAntiShake.clicksAntiShake(gameCloseWheat, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (imOff && gameMicManager != null) {
gameCloseWheat.post(new Runnable() {
@Override
public void run() {
if (disable) {
disable = false;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
LiveNetManager.get(mContext)
.onMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on");
} else {
disable = true;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
LiveNetManager.get(mContext)
.offMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off");
}
}
});
}
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_review_input), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
new XPopup.Builder(mContext)
.enableDrag(false)
.asCustom(new SudGameInputPopupWindow(mContext, new SudGameInputPopupWindow.SudGameInputCallBack() {
@Override
public void sendMessage(String textMessage) {
gameMicManager.sendMessage(textMessage);
}
}))
.show();
}
});
gameViewModel.gameViewLiveData.observe(this, new Observer<View>() {
@Override
public void onChanged(View view) {
if (view == null) { // 在关闭游戏时把游戏View给移除
gameContainer.removeAllViews();
} else { // 把游戏View添加到容器内
gameContainer.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
}
}
});
// 加载游戏参数定义可查看BaseGameViewModel.switchGame()方法注释
// 游戏配置
GameConfigModel gameConfigModel = gameViewModel.getGameConfigModel();
gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值
gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值
gameConfigModel.ui.lobby_game_setting.hide = true; // 配置不隐藏ping值
gameConfigModel.ui.gameSettle.hide = true;//是否隐藏结算界面false: 显示 true: 隐藏默认为 false
gameConfigModel.ui.lobby_players.custom = true;
gameConfigModel.ui.join_btn.custom = true;
gameConfigModel.ui.game_settle_again_btn.custom = true;
gameConfigModel.ui.start_btn.custom = true;
// SudMGP平台64bit游戏ID
gameViewModel.switchGame((Activity) mContext, mLiveUid, mInteractionID);
// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, -1, true, 1);
// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfCaptain(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
// ViewClicksAntiShake.clicksAntiShake(gameTitle, new ViewClicksAntiShake.ViewClicksCallBack() {
// @Override
// public void onViewClicks() {
//
// }
// });
// 设置游戏安全操作区域
GameViewInfoModel.GameViewRectModel gameViewRectModel = new GameViewInfoModel.GameViewRectModel();
gameViewRectModel.left = 0;
gameViewRectModel.top = DpUtil.dp2px(180);//游戏安全区域
gameViewRectModel.right = 0;
gameViewRectModel.bottom = DpUtil.dp2px(155);
gameViewModel.gameViewRectModel = gameViewRectModel;
//初始化结算弹窗
sudGameDoubleDialog = new SudGameDoubleDialog(this);//双人游戏
sudGameMultipleDialog = new SudGameMultipleDialog(this);//多人游戏
sudLoadDialog = new SudLoadDialog(this);//加载弹窗
//游戏结算结束
gameViewModel.listMutableLiveData.observe(this, sudSettleBeans -> {
if (sudLoadDialog.getClickStatus() == 0) {
sudLoadDialog.dismiss();
if (gameViewModel.getSudGameScoreBean().getGame_mode() == 1) {
//双人游戏
sudGameDoubleDialog.setSudSettleList(sudSettleBeans);
sudGameDoubleDialog.showDialog();
} else {
//多人游戏
sudGameMultipleDialog.setSudSettleList(sudSettleBeans);
sudGameMultipleDialog.showDialog();
}
}
});
//加载弹窗监听
sudLoadDialog.setOnDismissListener(() -> {
if (sudLoadDialog.getClickStatus() == 2){
Bus.get().post(new CheckRemainingBalanceEvent(null).setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN).setSubReady(false));
}
});
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onCheckRemainingBalanceEvent(CheckRemainingBalanceEvent event) {
switch (event.getSudMGPMGState()) {
case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN:
case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN:
//获取筹码信息检查是否足够
LiveNetManager.get(mContext).getScore(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<SudGameScoreBean>() {
@Override
public void onSuccess(SudGameScoreBean data) {
if (data.getGolden_bean_remaining_balance() == 1) {
gameViewModel.setSudGameScoreBean(data);
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1);
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfReady(event.getSubReady());
} else {
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("貨幣数量不足 ");
} else {
ToastUtil.show("Insufficient number of currency");
}
}
// ToastUtil.show(data.toString());
}
@Override
public void onError(String error) {
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("貨幣数量不足 ");
} else {
ToastUtil.show("Insufficient number of currency");
}
}
});
break;
case SudMGPMGState.MG_COMMON_GAME_SETTLE:
//结算状态
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1);
sudLoadDialog.setClickStatus(0);
sudLoadDialog.setDouble(gameViewModel.getSudGameScoreBean().getGame_mode());
sudLoadDialog.showDialog();
//获取用户信息
LiveNetManager.get(mContext).getSudGameInfo(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<List<SudGameInfoBean>>() {
@Override
public void onSuccess(List<SudGameInfoBean> data) {
if (!data.isEmpty()){
gameViewModel.setSudGameInfoBeanList(data);
gameViewModel.sudGameRank(event.getMgCommonGameSettle());
}else {
ToastUtil.show(getString(R.string.net_error));
}
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
break;
case SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN:
//点击开始游戏
LiveNetManager.get(mContext).gameStartCheckRemainingBalance(mCreateSudRoomModel.getSudGameId(),
mCreateSudRoomModel.getSudGameRoomId(), new
HttpCallback<CheckRemainingBalance>() {
@Override
public void onSuccess(CheckRemainingBalance data) {
if (data.getStatus() == 1) {
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfPlaying(true);
} else {
}
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
break;
case SudMGPMGState.MG_COMMON_GAME_STATE:
LiveNetManager.get(mContext).deductMoney(mCreateSudRoomModel.getSudGameRoomId());
break;
}
}
@Override
public void onJoinRoomSuccess(RCRTCRoom rcrtcRoom) {
LiveNetManager.get(mContext).getRoomMicData(mLiveUid, new HttpCallback<List<SudGameUserModel>>() {
@Override
public void onSuccess(List<SudGameUserModel> data) {
gameMicManager.refreshStreams(data);
sudGameUserListAdapter.refreshSudGameUserList(data, muteUser);
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
// 主动订阅远端用户发布的资源
// gameMicManager.subscribeAVStream();
}
@Override
public void onJoinRoomFailed(RTCErrorCode rtcErrorCode) {
ToastUtil.show("加入失败 " + rtcErrorCode.toString());
}
@Override
public void onPublishSuccess() {
runOnUiThread(new Runnable() {
@Override
public void run() {
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_hang_up : R.mipmap.icon_game_hang_up_en, gameSeat);
publishDefault = true;
gameCloseWheat.setVisibility(View.VISIBLE);
disable = false;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
}
});
LiveNetManager.get(mContext)
.joinMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
}
@Override
public void onPublishFailed() {
ToastUtil.show(WordUtil.isNewZh() ? "語音加入失敗" : "Voice joining failed");
}
@Override
public void onSubscribeSuccess(List<RCRTCInputStream> inputStreamList) {
// ToastUtil.show("订阅成功 ");
}
@Override
public void onSubscribeFailed() {
ToastUtil.show("订阅失败 ");
}
@Override
public void onSubscribeSuccess(String userID, boolean mute, int position) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mute) {
ToastUtil.show(WordUtil.isNewZh() ? "已靜音該用戶" : "The user has been muted");
} else {
ToastUtil.show(WordUtil.isNewZh() ? "已取消該用戶靜音" : "The user has been unmuted");
}
sudGameUserListAdapter.muteUser(userID, mute, position);
}
});
}
@Override
public void onSubscribeFailed(String userID) {
ToastUtil.show("订阅失败 ");
}
@Override
public void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser) {
}
@Override
public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
}
@Override
public void insertItem(SudGameChatImModel sudGameChatImModel) {
mLiveChatAdapter.insertItem(sudGameChatImModel);
}
@Override
public void refreshSudGameUserList(List<SudGameUserModel> personList) {
sudGameUserListAdapter.refreshSudGameUserList(personList, muteUser);
}
@Override
public void onUnPublishStreamsSuccess() {
runOnUiThread(new Runnable() {
@Override
public void run() {
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
publishDefault = false;
gameCloseWheat.setVisibility(View.INVISIBLE);
}
});
LiveNetManager.get(mContext)
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
}
@Override
public void onUnPublishStreamsFailed() {
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameSocketImEvent(SudGameSocketImEvent event) {
gameMicManager.processingMessage(event);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameUserModel(SudGameUserModel model) {
if (model.isNullUser()) {
if (!publishDefault) {
if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
if (sudGameUserListAdapter.isMicMax()) {
ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
} else {
gameMicManager.publishDefaultAVStream();
}
} else {
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
@Override
public void run() {
}
});
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "已經是上麥狀態" : "It is already in the wheat state");
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameStatus(SubGameEvent event) {
if (event.getType() == 0) {
Log.i("游戏回调", "onGameStateChange: event :" + event.toString());
if (event.getModel().getCode() == 1001 || event.getModel().getCode() == 1002) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("result", 0);
gameViewModel.sudFSTAPPDecorator.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_CREATE_ORDER_RESULT, jsonObject.toString());
}
}
}
}

View File

@ -79,11 +79,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
import cn.rongcloud.rtc.api.RCRTCRoom;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
@ -108,7 +103,6 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
private ProcessResultUtil mProcessResultUtil;
private List<String> muteUser = new ArrayList<>();
private boolean imOff;
private boolean isSw = CommonAppConfig.getInstance().getConfig().isSw();
private SudGameDoubleDialog sudGameDoubleDialog;//双人游戏弹窗
private SudGameMultipleDialog sudGameMultipleDialog;//多人游戏弹窗
private SudLoadDialog sudLoadDialog;//加载弹窗
@ -150,8 +144,6 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
}
});
// 设置禁用麦克风采集
//RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
gameCloseWheat.setVisibility(View.INVISIBLE);
@ -160,8 +152,6 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
@Override
public void onSuccess(RoomMicStatusModel data) {
gameMicManager = new GameSwMicManager();
gameMicManager.attachView(SudSwGameActivity.this);
gameMicManager.config(SudSwGameActivity.this);
//初始化声网引擎
SWAuManager.get().initRtcEngineAudio(mContext);
//语音
@ -196,13 +186,8 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
chatList.setVisibility(View.GONE);
}
gameMicManager.setmRoomID(mLiveUid);
if (isSw) {
SWAuManager.get().joinAudioRoom("v" + mLiveUid, CommonAppConfig.SWToken, Integer.parseInt(CommonAppConfig.getInstance().getUid()));
onJoinRoomSuccess(null);
onJoinSuccess();
} else {
gameMicManager.joinRoom(mLiveUid, imOff);
}
}
@Override
@ -242,7 +227,7 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
@Override
protected void onDestroy() {
if(isActivityGame){
if (isActivityGame) {
RandomSudGameManager.getManager().destroy();
}
LiveNetManager.get(mContext).leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@ -256,11 +241,8 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
}
});
if (isSw) {
SWAuManager.get().exitChannelAll();
}
if (gameMicManager != null) {
gameMicManager.leaveRoom();
gameMicManager.detachView();
}
@ -308,13 +290,9 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
@Override
public void unMute(String userID, int position) {
if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
if (isSw) {
//靜音
SWAuManager.get().setMicAudio(Integer.parseInt(userID), false);
onSubscribeSuccess(userID, false, position);
} else {
gameMicManager.refreshStreams(userID, false, position);
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
}
@ -325,13 +303,9 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
public void mute(String userID, int position) {
muteUser.add(userID);
if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
if (isSw) {
//开启声音
SWAuManager.get().setMicAudio(Integer.parseInt(userID), true);
onSubscribeSuccess(userID, true, position);
} else {
gameMicManager.refreshStreams(userID, true, position);
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
}
@ -378,26 +352,16 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
if (publishDefault) {
disable = true;
// 设置禁用麦克风采集
if (isSw) {
//下麥
SWAuManager.get().setMicAn(false);
onUnPublishStreamsSuccess();
} else {
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
// ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
gameMicManager.unPublishStreams();
}
} else {
if (sudGameUserListAdapter.isMicMax()) {
ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
} else {
//上麦
if (isSw) {
SWAuManager.get().setMicAn(true);
onPublishSuccess();
} else {
gameMicManager.publishDefaultAVStream();
}
}
}
} else {
@ -422,11 +386,7 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
if (disable) {
disable = false;
// 设置禁用麦克风采集
if (isSw) {
SWAuManager.get().setMicAn(true);
} else {
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
}
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
LiveNetManager.get(mContext).onMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
@ -442,12 +402,7 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on");
} else {
disable = true;
// 设置禁用麦克风采集
if (isSw) {
SWAuManager.get().setMicAn(false);
} else {
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
}
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
LiveNetManager.get(mContext).offMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
@ -553,8 +508,7 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
Bus.get().post(new CheckRemainingBalanceEvent(null).setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN).setSubReady(false));
}
});
LiveNetManager.get(mContext)
.checkGameForActivity(gameViewModel.getGameRoomId(), new HttpCallback<>() {
LiveNetManager.get(mContext).checkGameForActivity(gameViewModel.getGameRoomId(), new HttpCallback<>() {
@Override
public void onSuccess(SudGameActivityInfoRoomBean data) {
isActivityGame = data.getIsActivity() == 1;
@ -632,8 +586,8 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
LiveNetManager.get(mContext).checkGameForActivity(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<SudGameActivityInfoRoomBean>() {
@Override
public void onSuccess(SudGameActivityInfoRoomBean data) {
isActivityGame=data.getIsActivity()==1;
if(isActivityGame) {
isActivityGame = data.getIsActivity() == 1;
if (isActivityGame) {
sudLoadDialog.setActivityGame();
sudGameDoubleDialog.setActivityGame();
}
@ -677,12 +631,11 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
}
private void showDialog() {
DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh() ? "結算超時\n請前往活動頁面查看本局結果" :
"Settlement timed out\nPlease check the result on the event page Confirm.", new DialogUitl.SimpleCallback() {
DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh() ? "結算超時\n請前往活動頁面查看本局結果" : "Settlement timed out\nPlease check the result on the event page Confirm.", new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
dialog.dismiss();
if(sudLoadDialog.isShow()){
if (sudLoadDialog.isShow()) {
sudLoadDialog.dismiss();
}
}
@ -695,8 +648,7 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
showDialog();
return;
}
LiveNetManager.get(mContext)
.ballClearanceTableGetResultScore(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<>() {
LiveNetManager.get(mContext).ballClearanceTableGetResultScore(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<>() {
@Override
public void onSuccess(List<SudActivityGameInfoBean> data) {
if (data.isEmpty() && isActivityGame) {
@ -753,30 +705,6 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
}
}
@Override
public void onJoinRoomSuccess(RCRTCRoom rcrtcRoom) {
LiveNetManager.get(mContext).getRoomMicData(mLiveUid, new HttpCallback<List<SudGameUserModel>>() {
@Override
public void onSuccess(List<SudGameUserModel> data) {
gameMicManager.refreshStreams(data);
sudGameUserListAdapter.refreshSudGameUserList(data, muteUser);
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
// 主动订阅远端用户发布的资源
// gameMicManager.subscribeAVStream();
}
@Override
public void onJoinRoomFailed(RTCErrorCode rtcErrorCode) {
ToastUtil.show("加入失败 " + rtcErrorCode.toString());
}
@Override
public void onPublishSuccess() {
runOnUiThread(new Runnable() {
@ -786,8 +714,6 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
publishDefault = true;
gameCloseWheat.setVisibility(View.VISIBLE);
disable = false;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
}
});
@ -805,21 +731,6 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
});
}
@Override
public void onPublishFailed() {
ToastUtil.show(WordUtil.isNewZh() ? "語音加入失敗" : "Voice joining failed");
}
@Override
public void onSubscribeSuccess(List<RCRTCInputStream> inputStreamList) {
// ToastUtil.show("订阅成功 ");
}
@Override
public void onSubscribeFailed() {
ToastUtil.show("订阅失败 ");
}
@Override
public void onSubscribeSuccess(String userID, boolean mute, int position) {
runOnUiThread(new Runnable() {
@ -836,31 +747,6 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
}
@Override
public void onSubscribeFailed(String userID) {
ToastUtil.show("订阅失败 ");
}
@Override
public void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser) {
}
@Override
public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
}
@Override
public void insertItem(SudGameChatImModel sudGameChatImModel) {
mLiveChatAdapter.insertItem(sudGameChatImModel);
}
@Override
public void refreshSudGameUserList(List<SudGameUserModel> personList) {
sudGameUserListAdapter.refreshSudGameUserList(personList, muteUser);
}
@Override
public void onUnPublishStreamsSuccess() {
runOnUiThread(new Runnable() {
@ -885,14 +771,8 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
}
@Override
public void onUnPublishStreamsFailed() {
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameSocketImEvent(SudGameSocketImEvent event) {
gameMicManager.processingMessage(event);
}
@Subscribe(threadMode = ThreadMode.MAIN)

View File

@ -27,7 +27,6 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import java.util.Arrays;
@ -168,8 +167,6 @@ public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
if (yaoqing.size() < 5) {
if(mContext instanceof LiveSwAnchorActivity){
((LiveSwAnchorActivity) mContext).linkDrMicAnchorApply(bean.getId(), bean.getId());
}else{
((LiveRyAnchorActivity) mContext).linkDrMicAnchorApply(bean.getId(), bean.getId());
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "多人PK最大參與人數為4人" : "The maximum number of participants in a multiplayer PK is 4 people");
@ -205,10 +202,6 @@ public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
if(mContext instanceof LiveSwAnchorActivity){
((LiveSwAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(),
false);
}else{
((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(),
((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString()
);
}
}
} else {

View File

@ -29,8 +29,6 @@ import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.adapter.LivePkAdapter;
import com.yunbao.live.bean.LivePkBean;
@ -354,22 +352,16 @@ public class LiveLinkMicListDialogFragment extends AbsDialogFragment implements
// ToastUtil.show("多人");
if(mContext instanceof LiveSwAnchorActivity){
((LiveSwAnchorActivity) mContext).linkDrMicAnchorApply(bean.getUid(), bean.getStream());
}else{
((LiveRyAnchorActivity) mContext).linkDrMicAnchorApply(bean.getUid(), bean.getStream());
}
}else {
// ToastUtil.show("单人");
if(mContext instanceof LiveSwAnchorActivity){
((LiveSwAnchorActivity) mContext).linkMicAnchorApply(bean.getUid(), bean.getStream());
}else{
((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getUid(), bean.getStream());
}
}
}else{
if(mContext instanceof LiveSwAnchorActivity){
((LiveSwAnchorActivity) mContext).linkMicAnchorApply(bean.getUid(), bean.getStream());
}else{
((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getUid(), bean.getStream());
}
}
dismiss();

View File

@ -37,7 +37,6 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.LiveAnchorMessageCustomPopup;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.interfaces.LiveFunctionClickListener;
@ -160,8 +159,6 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
// }else{
if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).setBtnFunctionDark();
} else {
((LiveRyAnchorActivity) mContext).setBtnFunctionDark();
}
// }
super.onDestroy();
@ -224,8 +221,6 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
public void run() {
if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) (mContext)).mLiveRoomViewHolder.initAnchorSayData();
} else {
((LiveRyAnchorActivity) (mContext)).mLiveRoomViewHolder.initAnchorSayData();
}
}
}, 1000);

View File

@ -25,7 +25,6 @@ import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.NewLevelModel;
import com.yunbao.common.bean.UserBean;
@ -47,8 +46,6 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveReportActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.bean.ImpressBean;
import com.yunbao.live.custom.MyTextView;
import com.yunbao.live.utils.LiveTextRender;

View File

@ -20,8 +20,6 @@ import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.adapter.LiveWishListAdapter;
import com.yunbao.live.bean.LiveWishlistBean;
@ -195,8 +193,6 @@ public class LiveWishListDialogFragment extends AbsDialogFragment implements OnI
Log.e("ry",getTag());
if(mContext instanceof LiveSwAnchorActivity){
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
}else{
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
}
}

View File

@ -22,7 +22,6 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.common.http.LiveHttpUtil;
@ -269,7 +268,7 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
RandomPkManager.getInstance().exitPk();
return;
}
LiveHttpUtil.getMicList(isSw?LiveSwAnchorActivity.mLiveUid: LiveRyAnchorActivity.mLiveUid, 0, new HttpCallback() {
LiveHttpUtil.getMicList(LiveSwAnchorActivity.mLiveUid, 0, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
System.out.println("code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));

View File

@ -8,7 +8,6 @@ import static com.yunbao.live.activity.LiveSwAnchorActivity.PKing;
import static com.yunbao.live.activity.LiveSwAnchorActivity.isDRPK;
import static com.yunbao.live.activity.LiveSwAnchorActivity.mLiveAnchorViewHolder;
import static com.yunbao.live.views.LivePushSwViewHolder.btn_close;
import static com.yunbao.live.views.LivePushSwViewHolder.rtcRoom;
import android.app.Dialog;
import android.content.Context;
@ -35,21 +34,15 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.imsdk.v2.V2TIMSendCallback;
import com.tencent.trtc.TRTCCloud;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.AnchorInfoEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
@ -79,21 +72,11 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCMixConfig;
import cn.rongcloud.rtc.api.RCRTCOtherRoom;
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
import cn.rongcloud.rtc.api.callback.IRCRTCOtherRoomEventsListener;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.SWManager;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
@ -151,8 +134,8 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
public LivePushSwViewHolder livePushSwViewHolder;
public static List<RCRTCInputStream> inputStreamList = new ArrayList<>();
public static List<RCRTCInputStream> inputStreamList1 = new ArrayList<>();
// public static List<RCRTCInputStream> inputStreamList = new ArrayList<>();
// public static List<RCRTCInputStream> inputStreamList1 = new ArrayList<>();
private boolean DRInitiator = false;//是否是duorenPK发起人
private List<DrPkbean> drPkbeans = new ArrayList<>();
@ -337,15 +320,6 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
s1 = "00:00";
i = 0;
}
if (rtcRoom != null) {
ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith();
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
params.weight = 1;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
livePushSwViewHolder.camera.setLayoutParams(params);
livePushSwViewHolder.mPreView1.setLayoutParams(params);
}
Log.i("tts2", s1);
mLiveLinkMicPkViewHolder.setTime(s + " " + s1);
@ -863,86 +837,10 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
@Override
protected void onDRPkTimeout(UserBean u) {
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode errorCode) {
}
@Override
public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 8);
msg1.create();
String targetId = u.getId();
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(io.rong.imlib.model.Message message) {
}
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("ry", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
}
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("ry", "发送失敗" + mApplyUid);
}
});
}
});
}
@Override
protected void onDRPkRefuse(UserBean u) {
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode errorCode) {
}
@Override
public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 3);
msg1.create();
String targetId = u.getId();
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(io.rong.imlib.model.Message message) {
}
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("ry", "发送成功");
if (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
}
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("ry", "发送失敗");
}
});
}
});
}
@Override
@ -1054,7 +952,6 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
public void leaveDRRoom() {
//清理PK上面对方的头像
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
Log.e("ry", "退出多人OKKK" + inputStreamList.size());
isDRPK = 0;
DRPKing = -1;
runOnUiThread(new Runnable() {
@ -1169,7 +1066,7 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
}
private void refusePk(UserBean u) {
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra_randm_pk", new IRCRTCResultCallback() {
/*IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra_randm_pk", new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode errorCode) {
@ -1208,7 +1105,7 @@ public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements V
}
});
}
});
});*/
LiveNetManager.get(mContext).setBanRandomPK(null);
}

View File

@ -66,8 +66,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
/* if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");*/
}
@Override
@ -131,9 +131,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
if (SocketRyClient.mSocketHandler != null) {
/* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
LiveNetManager.get(CommonAppContext.sInstance)
.addChatCount(LiveActivity.mStream, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
@Override
@ -218,8 +218,8 @@ public class SocketRyChatUtil {
}
}
});
if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
/*if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");*/
}
@Override
@ -267,9 +267,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
/* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
}
@Override
@ -406,9 +406,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
/*if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
}
@Override
@ -476,9 +476,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
/* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
}
@Override
@ -523,9 +523,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
/* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
}
@Override
@ -560,9 +560,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
/* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
}
@Override
@ -603,8 +603,8 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
/* if (SocketRyClient.mSocketHandler != null)
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");*/
}
@Override
@ -640,9 +640,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
/* if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
}
@Override
@ -680,9 +680,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
/*if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
}
@Override
@ -786,9 +786,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
/*if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
}
@Override
@ -834,9 +834,9 @@ public class SocketRyChatUtil {
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
if (SocketRyClient.mSocketHandler != null) {
/*if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
}
}*/
LiveNetManager.get(CommonAppContext.sInstance)
.addChatCount(LiveActivity.mStream, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
@Override

File diff suppressed because it is too large Load Diff

View File

@ -1,211 +0,0 @@
package com.yunbao.live.socket;
import android.util.Log;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.message.TextMessage;
public class SocketRyLinkMicPkUtil {
/**
* 发起PK申请
*
* @param pkUid 对方主播的uid
* @param stream 自己直播间的stream
*/
public static void linkMicPkApply(SocketRyClient client, String pkUid, String stream) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
}
/**
* 主播接受对方主播的Pk请求
*
* @param pkUid 对方主播的uid
*/
public static void linkMicPkAccept(SocketRyClient client, String pkUid, String url, String name) {
HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive")
.params("uid", CommonAppConfig.getInstance().getUid())
.params("pkuid", pkUid)
.params("type", "1")
.params("sign", "1")
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msgs, String[] info) {
if (code == 0) {
HttpClient.getInstance().get("Livepk.setPK", "Livepk.setPK")
.params("uid", CommonAppConfig.getInstance().getUid())
.params("pkuid", pkUid)
.params("type", "1")
.params("sign", "1")
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msgs, String[] info) {
if (code == 0) {
Log.e("ry",name+"啊啊"+url);
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", Constants.SOCKET_LINK_MIC_PK)
.param("action", 4)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
.param("pkuid", pkUid)
.param("uid", CommonAppConfig.getInstance().getUid())
.param("pkhead", url)
.param("pkname", name);
msg1.create();
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
Message message1 = Message.obtain("g" + CommonAppConfig.getInstance().getUid(), conversationType, messageContent);
RongcloudIMManager.sendMessage(message1, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
}
});
}
}
});
}
/**
* 主播接受对方主播的Pk请求
*
* @param pkUid 对方主播的uid
*/
public static void linkMicDRPkAccept(String pkUid) {
}
/**
* 主播拒绝其他主播的连麦请求
*/
public static void linkMicPkRefuse(SocketRyClient client, String pkUid) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LINK_MIC_PK)
.param("action", 3)
.param("msgtype", 0)
.param("uid", u.getId())
.param("uname", u.getUserNiceName())
.param("pkuid", pkUid)
.param("ct", "");
msg.create();
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
Message message = Message.obtain(pkUid, conversationType, messageContent);
RongcloudIMManager.sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}
});
}
/**
* 主播断开连麦
*/
public static void linkMicAnchorClose(SocketRyClient client, String pkUid) {
if (client == null) {
return;
}
UserBean u = CommonAppConfig.getInstance().getUserBean();
if (u == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_LINK_MIC_PK)
// .param("action", 5)
// .param("msgtype", 0)
// .param("uid", u.getId())
// .param("ct", "")
// .param("pkuid", pkUid)
// .param("uname", u.getUserNiceName()));
}
/**
* 当收到主播连麦的请求时候主播正在忙
*/
public static void linkMicPkBusy(SocketClient client, String pkUid) {
if (client == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_LINK_MIC_PK)
// .param("action", 7)
// .param("msgtype", 10)
// .param("pkuid", pkUid));
}
/**
* 当收到主播连麦的请求时候主播无响应
*/
public static void linkMicPkNotResponse(SocketRyClient client, String pkUid) {
if (client == null) {
return;
}
// client.send(new SocketSendBean()
// .param("_method_", Constants.SOCKET_LINK_MIC_PK)
// .param("action", 8)
// .param("msgtype", 10)
// .param("pkuid", pkUid));
}
}

View File

@ -37,7 +37,6 @@ import com.yunbao.common.views.weight.ClipPathCircleImage;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.adapter.SearchRecommendBodyAdapter;
import com.yunbao.live.event.JumpUserHomeEvent;
@ -234,9 +233,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
goHomeUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mContext instanceof LiveRyAnchorActivity) {
((LiveRyAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveAudienceActivity) {
if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).superBackPressed();
@ -271,9 +268,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mContext instanceof LiveRyAnchorActivity) {
((LiveRyAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveAudienceActivity) {
if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).superBackPressed();
@ -375,8 +370,6 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveRyAnchorActivity) {
((LiveRyAnchorActivity) mContext).superBackPressed();
}
Bus.get().post(new CloseEvent());
}
@ -467,8 +460,6 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveRyAnchorActivity) {
((LiveRyAnchorActivity) mContext).superBackPressed();
}
}
}

View File

@ -1,981 +0,0 @@
package com.yunbao.live.views;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.interfaces.XPopupCallback;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LiveAnchorCallMeModel;
import com.yunbao.common.bean.LiveAnchorSayModel;
import com.yunbao.common.bean.LiveClassBean;
import com.yunbao.common.bean.LiveRoomTypeBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.event.LivePushRyEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpConsts;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.interfaces.ImageResultCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ProcessImageUtil;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.common.views.LiveClarityCustomPopup;
import com.yunbao.common.views.LiveNewWishListPopup;
import com.yunbao.common.views.LiveOpenCustomPopup;
import com.yunbao.common.views.LiveRobotSettingCustomPopup;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.faceunity.FaceManager;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.dialog.LiveAnchorEditCallMeDialog;
import com.yunbao.live.dialog.LiveAnchorSayPopDialog;
import com.yunbao.live.dialog.LiveFaceUnityDialogFragment;
import com.yunbao.live.dialog.LiveNewRoomClassDialogFragment;
import com.yunbao.live.dialog.LiveNewRoomTypeDialogFragment;
import com.yunbao.live.dialog.LiveTimeDialogFragment;
import com.yunbao.live.event.LiveAudienceEvent;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File;
import java.util.Locale;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.stream.RCRTCCameraOutputStream;
import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig;
import cn.rongcloud.rtc.base.RCRTCParamsType;
public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnClickListener {
private ConstraintLayout mAvatar, mRootView;
private TextView mCoverText;
private EditText mEditTitle;
private ProcessImageUtil mImageUtil;
private File mAvatarFile;
private TextView mLiveClass, anchorAgreement;
private TextView mLiveTypeTextView, liveClarity;//房间类型TextView
private TextView mLiveWishListTextView;//心愿单TextView
private int mLiveClassID;//直播频道id
private int mLiveType;//房间类型
private int mLiveTypeVal;//房间密码门票收费金额
private int mLiveTimeCoin;//计时收费金额
private boolean mOpenLocation = true;
private int mLiveSdk;
private LiveClassBean classBean;
private FaceManager manager;
private TextView faceTextView;//提示人脸未检测到的TextView
private ImageView imgClarity, selectorProtocol;
private int selectClarity = 1;
private LiveOpenCustomPopup liveOpenCustomPopup;
private boolean selector = true;
private String mLiveUid;
public LiveNewReadyRyViewHolder(Context context, ViewGroup parentView, int liveSdk) {
super(context, parentView, liveSdk);
}
@Override
protected void processArguments(Object... args) {
if (args.length > 0) {
mLiveSdk = (int) args[0];
}
}
@Override
protected int getLayoutId() {
return R.layout.view_new_live_ready;
}
@Override
public void init() {
mRootView = (ConstraintLayout) findViewById(R.id.traceroute_rootview);
imgClarity = (ImageView) findViewById(R.id.img_clarity);
selectorProtocol = (ImageView) findViewById(R.id.selector_protocol);
liveClarity = (TextView) findViewById(R.id.live_clarity);
anchorAgreement = (TextView) findViewById(R.id.anchor_agreement);
mRootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
InputMethodManager imm = (InputMethodManager)
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
});
mAvatar = (ConstraintLayout) findViewById(R.id.avatar);
mAvatar.setOnClickListener(this);
UserBean u = CommonAppConfig.getInstance().getUserBean();
ImgLoader.displayDrawable(mContext, u.getAvatar(), new ImgLoader.DrawableCallback() {
@Override
public void onLoadSuccess(Drawable drawable) {
mAvatar.setBackground(drawable);
}
@Override
public void onLoadFailed() {
}
});
mCoverText = (TextView) findViewById(R.id.cover_text);
mEditTitle = (EditText) findViewById(R.id.edit_title);
findViewById(R.id.btn_room_type).setOnClickListener(this);
mOpenLocation = true;
mLiveClass = (TextView) findViewById(R.id.live_class);
mLiveTypeTextView = (TextView) findViewById(R.id.text_room_type);
mLiveWishListTextView = (TextView) findViewById(R.id.text_wishlist);
faceTextView = (TextView) findViewById(R.id.faceTextView);
mImageUtil = ((LiveActivity) mContext).getProcessImageUtil();
mImageUtil.setImageResultCallback(new ImageResultCallback() {
@Override
public void beforeCamera() {
((LiveRyAnchorActivity) mContext).beforeCamera();
}
@Override
public void onSuccess(File file) {
if (file != null) {
ImgLoader.displayFileDrawable(mContext, file, new ImgLoader.DrawableCallback() {
@Override
public void onLoadSuccess(Drawable drawable) {
mAvatar.setBackground(drawable);
}
@Override
public void onLoadFailed() {
}
});
if (mAvatarFile == null) {
mCoverText.setText(mContext.getString(R.string.live_cover_2));
mCoverText.setBackground(ContextCompat.getDrawable(mContext, R.drawable.bg_live_cover));
}
mAvatarFile = file;
}
}
@Override
public void onFailure() {
}
});
findViewById(R.id.btn_camera).setOnClickListener(this);
findViewById(R.id.btn_live_class).setOnClickListener(this);
findViewById(R.id.btn_close).setOnClickListener(this);
findViewById(R.id.btn_beauty).setOnClickListener(this);
findViewById(R.id.btn_robot).setOnClickListener(this);
findViewById(R.id.btn_start_live).setOnClickListener(this);
findViewById(R.id.btn_wishlist).setOnClickListener(this);
findViewById(R.id.btn_horizontally).setOnClickListener(this);
findViewById(R.id.anchor_agreement_layout).setOnClickListener(this);
findViewById(R.id.btn_live_anchor_say).setOnClickListener(this);
findViewById(R.id.btn_live_anchor_call_me).setOnClickListener(this);
if (manager != null) {
manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
final Handler handler = new Handler(Looper.getMainLooper());
@Override
public void onFaceChanged(int num) {
handler.post(() -> {
if (num == 0) {
faceTextView.setVisibility(View.VISIBLE);
} else {
faceTextView.setVisibility(View.GONE);
}
});
}
});
//新美颜
setFaceUnity(true);
}
//设置清晰度
// DeviceUtils.getMemory(mContext); //获取可用内存
// DeviceUtils.getNetSpeed(mContext);//获取当前上传网速
// Log.e("网速和内存", "内存:" + + " 网速:" + DeviceUtils.getNetSpeed(mContext));
IMLoginManager.get(mContext).setSelectClarity(selectClarity);
setSelectClarity(IMLoginManager.get(mContext).getSelectClarity());
ViewClicksAntiShake
.clicksAntiShake(
findViewById(R.id.btn_live_clarity), () -> {
LiveClarityCustomPopup liveClarityCustomPopup =
new LiveClarityCustomPopup(mContext,
IMLoginManager.get(mContext).getSelectClarity(),
IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
new XPopup.Builder(mContext)
.setPopupCallback(new XPopupCallback() {
@Override
public void onCreated(BasePopupView popupView) {
}
@Override
public void beforeShow(BasePopupView popupView) {
}
@Override
public void onShow(BasePopupView popupView) {
}
@Override
public void onDismiss(BasePopupView popupView) {
setSelectClarity(liveClarityCustomPopup.getSelectClarity());
}
@Override
public void beforeDismiss(BasePopupView popupView) {
}
@Override
public boolean onBackPressed(BasePopupView popupView) {
return false;
}
@Override
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
}
@Override
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
}
@Override
public void onClickOutside(BasePopupView popupView) {
}
})
.asCustom(liveClarityCustomPopup)
.show();
});
String keywordHtml2 = "</font><font color='#FF8D41'size='42px'>" + mContext.getString(R.string.anchor_hint) + "</font>";
String contextHtml = "<font color='#ffffff'size='42px'>" + mContext.getString(R.string.anchor_agreement) + "</font>";
anchorAgreement.setText(Html.fromHtml(contextHtml + keywordHtml2));
selectorProtocol.setPressed(true);
selectorProtocol.setSelected(true);
selector = selectorProtocol.isSelected();
selectorProtocol.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selector = !selector;
selectorProtocol.setSelected(selector);
}
});
}
private void setSelectClarity(int selectClarity) {
this.selectClarity = selectClarity;
IMLoginManager.get(mContext).setSelectClarity(selectClarity);
switch (selectClarity) {
case 0:
imgClarity.setImageResource(R.mipmap.icon_sd);
liveClarity.setText(R.string.standard_clear);
break;
case 1:
imgClarity.setImageResource(R.mipmap.icon_hd);
liveClarity.setText(R.string.high_definition);
break;
case 2:
imgClarity.setImageResource(R.mipmap.icon_fhd);
liveClarity.setText(R.string.ultra_hd);
break;
}
if (liveOpenCustomPopup != null) {
liveOpenCustomPopup.setSelectClarity(selectClarity);
}
//設置開播分辨率
RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
int minRate = 200;
int maxRate = 900;
switch (selectClarity) {
case 0:
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
minRate = 200;
maxRate = 900;
break;
case 1:
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280;
minRate = 250;
maxRate = 2200;
break;
case 2:
rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_1080_1920;
minRate = 400;
maxRate = 4000;
break;
}
RCRTCVideoStreamConfig config =
RCRTCVideoStreamConfig.Builder.create()
.setMinRate(minRate)
.setMaxRate(maxRate)
.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_15)
.setVideoResolution(rcrtcVideoResolution)
.build();
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config);
Log.e("切换分辨率", "时间戳" + System.currentTimeMillis());
//重新发布一下流
Bus.get().post(new LivePushRyEvent());
}
public void setManager(FaceManager manager) {
this.manager = manager;
}
@Override
public void onClick(View v) {
if (!canClick()) {
return;
}
int i = v.getId();
if (i == R.id.avatar) {
setAvatar();
} else if (i == R.id.btn_camera) {
toggleCamera();
} else if (i == R.id.btn_close) {
close();
} else if (i == R.id.btn_live_class) {
chooseLiveClass();
} else if (i == R.id.btn_beauty) {
//beauty();//momo美颜
setFaceUnity(false); //新娱美颜
} else if (i == R.id.btn_wishlist) {
//点击心愿单
openWishListWindow();
} else if (i == R.id.btn_room_type) {
chooseLiveType();
} else if (i == R.id.btn_start_live) {
if (!selector) {
ToastUtil.show(mContext.getString(R.string.anchor_agreement_hint));
return;
}
if (mLiveClassID == 0) {
ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
return;
}
// startLive();
liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, IMLoginManager.get(mContext).getSelectClarity(), classBean, liveRoomTypeBean)
.setSayStatus(IMLoginManager.get(mContext).getAnchorSayStatus())
.setCallMeStatus(IMLoginManager.get(mContext).getAnchorCallStatus())
.setCallBack(new LiveOpenCustomPopup.LiveOpenCallBack() {
@Override
public void startLive(LiveRoomTypeBean liveRoomTypeModel, LiveClassBean classModel) {
if (classModel != null) {
classBean = classModel;
mLiveClassID = classBean.getId();
}
liveRoomTypeBean = liveRoomTypeModel;
mLiveType = liveRoomTypeModel.getId();
startLiveInit();
liveOpenCustomPopup = null;
}
@Override
public void selectClarity(int selectClarity) {
LiveClarityCustomPopup liveClarityCustomPopup =
new LiveClarityCustomPopup(mContext,
IMLoginManager.get(mContext).getSelectClarity(),
IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
new XPopup.Builder(mContext)
.setPopupCallback(new XPopupCallback() {
@Override
public void onCreated(BasePopupView popupView) {
}
@Override
public void beforeShow(BasePopupView popupView) {
}
@Override
public void onShow(BasePopupView popupView) {
}
@Override
public void onDismiss(BasePopupView popupView) {
setSelectClarity(liveClarityCustomPopup.getSelectClarity());
}
@Override
public void beforeDismiss(BasePopupView popupView) {
}
@Override
public boolean onBackPressed(BasePopupView popupView) {
return false;
}
@Override
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
}
@Override
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
}
@Override
public void onClickOutside(BasePopupView popupView) {
}
})
.asCustom(liveClarityCustomPopup)
.show();
}
@Override
public void openRobot() {
LiveRobotSettingCustomPopup liveRobotSettingCustomPopup = new LiveRobotSettingCustomPopup(mContext);
new XPopup.Builder(mContext)
.setPopupCallback(new XPopupCallback() {
@Override
public void onCreated(BasePopupView popupView) {
}
@Override
public void beforeShow(BasePopupView popupView) {
}
@Override
public void onShow(BasePopupView popupView) {
}
@Override
public void onDismiss(BasePopupView popupView) {
if (liveOpenCustomPopup != null) {
liveOpenCustomPopup.initDate();
}
}
@Override
public void beforeDismiss(BasePopupView popupView) {
}
@Override
public boolean onBackPressed(BasePopupView popupView) {
return false;
}
@Override
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
}
@Override
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
}
@Override
public void onClickOutside(BasePopupView popupView) {
}
})
.asCustom(liveRobotSettingCustomPopup)
.show();
}
@Override
public void openLiveRoomType(LiveRoomTypeBean liveRoomTypeModel) {
liveRoomTypeBean = liveRoomTypeModel;
mLiveType = liveRoomTypeModel.getId();
chooseLiveType();
}
@Override
public void openLiveClass(LiveClassBean classModel) {
if (classModel != null) {
classBean = classModel;
mLiveClassID = classBean.getId();
}
chooseLiveClass();
}
@Override
public void openWishlist() {
//点击心愿单
openWishListWindow();
}
@Override
public void openAnchorSay() {
openAnchorSayDialog();
}
@Override
public void openCallMe() {
openAnchorCallMeDialog();
}
});
new XPopup.Builder(mContext)
.asCustom(liveOpenCustomPopup)
.show();
} else if (i == R.id.btn_locaiton) {
switchLocation();
} else if (i == R.id.btn_horizontally) {
RCRTCCameraOutputStream cameraStream = RCRTCEngine.getInstance().getDefaultVideoStream();
cameraStream.setPreviewMirror(!cameraStream.isPreviewMirror());
} else if (i == R.id.btn_robot) {
new XPopup.Builder(mContext)
.asCustom(new LiveRobotSettingCustomPopup(mContext))
.show();
} else if (i == R.id.anchor_agreement_layout) {
String ct = Locale.getDefault().getLanguage();
IMLoginModel model = IMLoginManager.get(mContext).getUserInfo();
StringBuffer url = new StringBuffer();
url.append(CommonAppConfig.HOST);
if (TextUtils.equals(ct, "zh")) {
url.append("/index.php?g=portal&m=page&a=index&id=671");
} else {
url.append("/index.php?g=portal&m=page&a=index&id=672");
}
url.append("&uid=")
.append(model.getId())
.append("&token=")
.append(model.getToken()).append("&isZh=")
.append(WordUtil.isNewZh() ? "1" : 0);
RouteUtil.forwardLiveZhuangBanActivity(url.toString(), false);
} else if (i == R.id.btn_live_anchor_say) {
openAnchorSayDialog();
} else if (i == R.id.btn_live_anchor_call_me) {
openAnchorCallMeDialog();
}
}
/**
* 新娱美颜
*/
public void setFaceUnity(boolean init) {
LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext);
fragment.setManager(manager);
fragment.setDismissShowUi(mRootView);
if (mContext instanceof LiveRyAnchorActivity) {
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity");
mRootView.setVisibility(View.INVISIBLE);
if (init) {
fragment.dismiss();
}
}
}
/**
* 打开心愿单窗口
*/
public void openWishListWindow() {
// LiveNewWishListDialogFragment fragment = new LiveNewWishListDialogFragment();
//
// if (mContext instanceof LiveRyAnchorActivity) {
// fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY");
//
// }
new XPopup.Builder(mContext)
.enableDrag(false)
.asCustom(new LiveNewWishListPopup((LiveRyAnchorActivity) mContext))
.show();
}
public void openAnchorSayDialog() {
new LiveAnchorSayPopDialog(mContext).setLiveUid(mLiveUid).setOnItemClickListener(new OnItemClickListener<LiveAnchorSayModel>() {
@Override
public void onItemClick(LiveAnchorSayModel bean, int position) {
if (liveOpenCustomPopup != null) {
liveOpenCustomPopup.setSayStatus(bean.getLivePreview().getIsShow() == 1);
}
}
}).showDialog();
}
public void openAnchorCallMeDialog() {
new LiveAnchorEditCallMeDialog(mContext).setLiveUid(mLiveUid).setOnItemClickListener(new OnItemClickListener<LiveAnchorCallMeModel>() {
@Override
public void onItemClick(LiveAnchorCallMeModel bean, int position) {
if (liveOpenCustomPopup != null) {
liveOpenCustomPopup.setCallMeStatus(bean.getIsShow() == 1);
}
}
}).showDialog();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void updateStart(LiveAudienceEvent event) {
if (event.getType() == WISH_LIST_UPDATE) {
if (liveOpenCustomPopup != null) {
liveOpenCustomPopup.initDate();
}
}
}
/**
* 打开 关闭位置
*/
private void switchLocation() {
if (mOpenLocation) {
new DialogUitl.Builder(mContext)
.setContent(mContext.getString(R.string.live_location_close_3))
.setCancelable(true)
.setConfirmString(mContext.getString(R.string.live_location_close_2))
.setClickCallback(new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
toggleLocation();
}
})
.build()
.show();
} else {
toggleLocation();
}
}
private void toggleLocation() {
mOpenLocation = !mOpenLocation;
}
/**
* 设置头像
*/
private void setAvatar() {
if (mLiveSdk == Constants.LIVE_SDK_TX) {
mImageUtil.getImageByAlbum();
} else {
DialogUitl.showStringArrayDialog(mContext, new Integer[]{
R.string.camera, R.string.alumb}, new DialogUitl.StringArrayDialogCallback() {
@Override
public void onItemClick(String text, int tag) {
if (tag == R.string.camera) {
mImageUtil.getImageByCamera();
} else {
mImageUtil.getImageByAlbum();
}
}
});
}
}
/**
* 切换镜头
*/
private void toggleCamera() {
((LiveRyAnchorActivity) mContext).toggleCamera();
}
/**
* 关闭
*/
private void close() {
((LiveRyAnchorActivity) mContext).endLives();
}
/**
* 选择直播频道
*/
private void chooseLiveClass() {
/* try {
Intent intent = new Intent(mContext, LiveChooseClassActivity.class);
intent.putExtra(Constants.CLASS_ID, mLiveClassID);
mImageUtil.startActivityForResult(intent, mActivityResultCallback);
}catch (Exception e){
}*/
Bundle bundle = new Bundle();
bundle.putInt(Constants.CLASS_ID, mLiveClassID);
LiveNewRoomClassDialogFragment fragment = new LiveNewRoomClassDialogFragment();
fragment.setArguments(bundle);
fragment.setCallback(new CommonCallback<LiveClassBean>() {
@Override
public void callback(LiveClassBean bean) {
classBean = bean;
mLiveClassID = classBean.getId();
mLiveClass.setText(bean.getName());
if (liveOpenCustomPopup != null) {
liveOpenCustomPopup.setClassBean(classBean);
}
}
});
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
}
/**
* 设置美颜
*/
private void beauty() {
((LiveRyAnchorActivity) mContext).beauty();
// Intent intent = new Intent(mContext, Beauty360Activity3.class);
// mContext.startActivity(intent);
}
/**
* 选择直播类型
*/
private LiveRoomTypeBean liveRoomTypeBean = new LiveRoomTypeBean(0, mContext.getString(R.string.live_room_public));
private void chooseLiveType() {
Bundle bundle = new Bundle();
bundle.putInt(Constants.CHECKED_ID, mLiveType);
LiveNewRoomTypeDialogFragment fragment = new LiveNewRoomTypeDialogFragment();
fragment.setArguments(bundle);
fragment.setCallback(new CommonCallback<LiveRoomTypeBean>() {
@Override
public void callback(LiveRoomTypeBean bean) {
liveRoomTypeBean = bean;
switch (bean.getId()) {
case Constants.LIVE_TYPE_NORMAL:
onLiveTypeNormal(bean);
break;
case Constants.LIVE_TYPE_PWD:
onLiveTypePwd(bean);
break;
case Constants.LIVE_TYPE_PAY:
onLiveTypePay(bean);
break;
case Constants.LIVE_TYPE_TIME:
onLiveTypeTime(bean);
break;
}
if (liveOpenCustomPopup != null) {
liveOpenCustomPopup.setLiveRoomTypeBean(liveRoomTypeBean);
}
}
});
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
}
/**
* 普通房间
*/
private void onLiveTypeNormal(LiveRoomTypeBean bean) {
mLiveType = bean.getId();
mLiveTypeTextView.setText(bean.getName());
mLiveTypeVal = 0;
mLiveTimeCoin = 0;
}
/**
* 密码房间
*/
private void onLiveTypePwd(final LiveRoomTypeBean bean) {
DialogUitl.showSimpleInputDialog(mContext, mContext.getString(R.string.live_set_pwd), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, 8, new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
if (TextUtils.isEmpty(content)) {
ToastUtil.show(mContext.getString(R.string.live_set_pwd_empty));
} else {
mLiveType = bean.getId();
mLiveTypeTextView.setText(WordUtil.isNewZh() ? "密碼房" : "password room");
if (StringUtil.isInt(content)) {
mLiveTypeVal = Integer.parseInt(content);
}
mLiveTimeCoin = 0;
dialog.dismiss();
}
}
});
}
/**
* 付费房间
*/
private void onLiveTypePay(final LiveRoomTypeBean bean) {
DialogUitl.showSimpleInputDialog(mContext, mContext.getString(R.string.live_set_fee), DialogUitl.INPUT_TYPE_NUMBER, 8, new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
if (TextUtils.isEmpty(content)) {
ToastUtil.show(mContext.getString(R.string.live_set_fee_empty));
} else {
mLiveType = bean.getId();
mLiveTypeTextView.setText(bean.getName());
if (StringUtil.isInt(content)) {
mLiveTypeVal = Integer.parseInt(content);
}
mLiveTimeCoin = 0;
dialog.dismiss();
}
}
});
}
/**
* 计时房间
*/
private void onLiveTypeTime(final LiveRoomTypeBean bean) {
LiveTimeDialogFragment fragment = new LiveTimeDialogFragment();
Bundle bundle = new Bundle();
bundle.putInt(Constants.CHECKED_COIN, mLiveTimeCoin);
fragment.setArguments(bundle);
fragment.setCommonCallback(new CommonCallback<Integer>() {
@Override
public void callback(Integer coin) {
mLiveType = bean.getId();
mLiveTypeTextView.setText(bean.getName());
mLiveTypeVal = coin;
mLiveTimeCoin = coin;
}
});
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveTimeDialogFragment");
}
public void hide() {
if (mContentView != null && mContentView.getVisibility() == View.VISIBLE) {
mContentView.setVisibility(View.INVISIBLE);
}
}
public void show() {
if (mContentView != null && mContentView.getVisibility() != View.VISIBLE) {
mContentView.setVisibility(View.VISIBLE);
}
}
/**
* 点击开始直播按钮
*/
private void startLiveInit() {
if (isWifiProxy(mContext) || checkVPN((ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE))) {
ToastUtil.show(WordUtil.isNewZh() ? "檢測開啓了VPN或者代理請先關閉VPN或者代理再開播。" :
"It is detected that VPN or proxy is turned on. Please turn off VPN or proxy before starting the broadcast.");
} else {
boolean startPreview = ((LiveRyAnchorActivity) mContext).isStartPreview();
// if (!startPreview) {
// ToastUtil.show(R.string.please_wait);
// return;
// }
if (mLiveClassID == 0) {
ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
return;
}
createRoom();
}
}
private boolean isWifiProxy(Context context) {
final boolean IS_ICS_OR_LATER = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
String proxyAddress;
int proxyPort;
if (IS_ICS_OR_LATER) {
proxyAddress = System.getProperty("http.proxyHost");
String portStr = System.getProperty("http.proxyPort");
proxyPort = Integer.parseInt((portStr != null ? portStr : "-1"));
} else {
proxyAddress = android.net.Proxy.getHost(context);
proxyPort = android.net.Proxy.getPort(context);
}
return (!TextUtils.isEmpty(proxyAddress)) && (proxyPort != -1);
}
private boolean checkVPN(ConnectivityManager connMgr) {
//don't know why always returns null:
NetworkInfo networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_VPN);
boolean isVpnConn = networkInfo == null ? false : networkInfo.isConnected();
return isVpnConn;
}
/**
* 请求创建直播间接口开始直播
*/
boolean isHttpBack = false;
private void createRoom() {
if (!isHttpBack) {
isHttpBack = true;
if (mLiveClassID == 0) {
ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
return;
}
String title = mEditTitle.getText().toString().trim();
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, IMLoginManager.get(mContext).getSelectClarity() + 1, false, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, final String[] info) {
isHttpBack = false;
if (code == 0 && info.length > 0) {
L.e("开播", "createRoom------->" + info[0]);
final CommonAppConfig appConfig = CommonAppConfig.getInstance();
UserBean u = appConfig.getUserBean();
((LiveRyAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
} else {
ToastUtil.show(msg);
}
}
@Override
public void onError() {
super.onError();
isHttpBack = false;
}
});
} else {
ToastUtil.show("請求中,請勿重複點擊");
}
}
public void release() {
mImageUtil = null;
}
@Override
public void onDestroy() {
LiveHttpUtil.cancel(LiveHttpConsts.CREATE_ROOM);
}
public void setLiveUid(String mLiveUid) {
this.mLiveUid = mLiveUid;
}
}

View File

@ -68,7 +68,6 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
@ -1083,10 +1082,8 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
/**
* 把观众转换成主播
*/
public List<RCRTCInputStream> userinputStreamList = new ArrayList<>();
public void UsertoRY() {
userinputStreamList.clear();
Log.e("ry", "主播同意了UsertoRY");
joinLiveMic();
}

View File

@ -3,8 +3,6 @@ package com.yunbao.live.views;
import static com.yunbao.live.activity.LiveActivity.mLiveSwLinkMicPkPresenter;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_END;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_ING;
import static com.yunbao.live.presenter.LiveSwLinkMicPkPresenter.inputStreamList;
import static com.yunbao.live.presenter.LiveSwLinkMicPkPresenter.inputStreamList1;
import static com.yunbao.live.presenter.LiveSwLinkMicPkPresenter.mPkUid;
import android.app.Activity;
@ -62,14 +60,6 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCMixConfig;
import cn.rongcloud.rtc.api.RCRTCRoom;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo;
import cn.rongcloud.rtc.base.RCRTCParamsType;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.agora.beautyapi.faceunity.agora.SWManager;
import io.rong.imlib.IRongCallback;
@ -93,8 +83,8 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
public static Context contexts;
public static TextView btn_close;
public LinearLayout dr_pk_view;
public static RCRTCRoom rtcRoom;
public static RCRTCLiveInfo rcrtcLiveInfo;
// public static RCRTCRoom rtcRoom;
// public static RCRTCLiveInfo rcrtcLiveInfo;
private ViewGroup liveActivityContainer;
public FrameLayout timeTitle;
public TextView textTime;
@ -441,8 +431,8 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
if (mPreView1.getVisibility() == View.VISIBLE) {
mPreView1.removeAllViews();
mPreView1.setVisibility(View.GONE);
inputStreamList.clear();
inputStreamList1.clear();
// inputStreamList.clear();
// inputStreamList1.clear();
}
}
@ -505,23 +495,6 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
mPaused = false;
Log.i("摄像头", "onResume: " + isNeedOpenCamera);
swManager.resetCamera();
if (isNeedOpenCamera) {
/*RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(new IRCRTCResultDataCallback<Boolean>() {
@Override
public void onSuccess(Boolean data) {
//设置摄像头最大缩放比例
boolean zoom = RCRTCEngine.getInstance().getDefaultVideoStream().setCameraZoomFactor(1.0f);
// ToastUtil.show("设置比例="+zoom);
Log.i("摄像头", "onSuccess: 打开摄像头");
isNeedOpenCamera = false;
}
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.i("摄像头", "onFailed: 打开摄像头失败 " + errorCode);
}
});*/
}
}
@Override
@ -553,7 +526,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
onDestroy();
SWManager.get().release();
LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM);
rtcRoom = null;
// rtcRoom = null;
}
@Override
@ -631,7 +604,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
@Subscribe(threadMode = ThreadMode.MAIN)
public void setSelectClarity(LivePushRyEvent event) {
if (rtcRoom != null)
/* if (rtcRoom != null)
rtcRoom.getLocalUser().publishDefaultLiveStreams(new IRCRTCResultDataCallback<RCRTCLiveInfo>() {
@Override
public void onSuccess(RCRTCLiveInfo rcrtcLiveInfo1) {
@ -642,7 +615,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
public void onFailed(RTCErrorCode rtcErrorCode) {
Log.e("ry", "rtcErrorCode" + rtcErrorCode);
}
});
});*/
}
public void setEnableBeauty(boolean flag) {

View File

@ -1,528 +0,0 @@
package com.yunbao.live.views;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.ActivityResultCallback;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.interfaces.ImageResultCallback;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ProcessImageUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveChooseClassActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.adapter.LiveReadyShareAdapter;
import com.yunbao.common.bean.LiveRoomTypeBean;
import com.yunbao.live.dialog.LiveRoomTypeDialogFragment;
import com.yunbao.live.dialog.LiveTimeDialogFragment;
import com.yunbao.live.dialog.LiveWishListDialogFragment;
import com.yunbao.common.http.LiveHttpConsts;
import com.yunbao.common.http.LiveHttpUtil;
import java.io.File;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.stream.RCRTCCameraOutputStream;
public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClickListener {
private ImageView mAvatar;
private TextView mCoverText;
private EditText mEditTitle;
private RecyclerView mLiveShareRecyclerView;
private LiveReadyShareAdapter mLiveShareAdapter;
private ProcessImageUtil mImageUtil;
private File mAvatarFile;
private TextView mCity;
private ImageView mLocationImg;
private TextView mLiveClass;
private TextView mLiveTypeTextView;//房间类型TextView
private TextView mLiveWishListTextView;//心愿单TextView
private int mLiveClassID;//直播频道id
private int mLiveType;//房间类型
private int mLiveTypeVal;//房间密码门票收费金额
private int mLiveTimeCoin;//计时收费金额
private ActivityResultCallback mActivityResultCallback;
private CommonCallback<LiveRoomTypeBean> mLiveTypeCallback;
private boolean mOpenLocation = true;
private int mLiveSdk;
public LiveReadyRyViewHolder(Context context, ViewGroup parentView, int liveSdk) {
super(context, parentView, liveSdk);
}
@Override
protected void processArguments(Object... args) {
if (args.length > 0) {
mLiveSdk = (int) args[0];
}
}
@Override
protected int getLayoutId() {
return R.layout.view_live_ready;
}
@Override
public void init() {
RelativeLayout traceroute_rootview = (RelativeLayout)findViewById(R.id.traceroute_rootview);
traceroute_rootview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
InputMethodManager imm = (InputMethodManager)
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
});
mAvatar = (ImageView) findViewById(R.id.avatar);
UserBean u = CommonAppConfig.getInstance().getUserBean();
ImgLoader.displayAvatar(mContext, u.getAvatar(), mAvatar);
mCoverText = (TextView) findViewById(R.id.cover_text);
mEditTitle = (EditText) findViewById(R.id.edit_title);
mCity = (TextView) findViewById(R.id.city);
mCity.setText(CommonAppConfig.getInstance().getCity());
mLocationImg = (ImageView) findViewById(R.id.location_img);
findViewById(R.id.btn_locaiton).setOnClickListener(this);
findViewById(R.id.btn_live_class).setOnClickListener(this);
mOpenLocation = true;
mLiveClass = (TextView) findViewById(R.id.live_class);
mLiveTypeTextView = (TextView) findViewById(R.id.btn_room_type);
findViewById(R.id.btn_horizontally).setOnClickListener(this);
mLiveWishListTextView= (TextView) findViewById(R.id.btn_wishlist);
mLiveShareRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
mLiveShareRecyclerView.setHasFixedSize(true);
mLiveShareRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
mLiveShareAdapter = new LiveReadyShareAdapter(mContext);
mLiveShareRecyclerView.setAdapter(mLiveShareAdapter);
mImageUtil = ((LiveActivity) mContext).getProcessImageUtil();
mImageUtil.setImageResultCallback(new ImageResultCallback() {
@Override
public void beforeCamera() {
((LiveRyAnchorActivity) mContext).beforeCamera();
}
@Override
public void onSuccess(File file) {
if (file != null) {
ImgLoader.display(mContext, file, mAvatar);
if (mAvatarFile == null) {
mCoverText.setText(mContext.getString(R.string.live_cover_2));
mCoverText.setBackground(ContextCompat.getDrawable(mContext, R.drawable.bg_live_cover));
}
mAvatarFile = file;
}
}
@Override
public void onFailure() {
}
});
findViewById(R.id.avatar_group).setOnClickListener(this);
findViewById(R.id.btn_camera).setOnClickListener(this);
findViewById(R.id.btn_close).setOnClickListener(this);
findViewById(R.id.btn_beauty).setOnClickListener(this);
findViewById(R.id.btn_start_live).setOnClickListener(this);
mLiveTypeTextView.setOnClickListener(this);
mLiveWishListTextView.setOnClickListener(this);
mActivityResultCallback = new ActivityResultCallback() {
@Override
public void onSuccess(Intent intent) {
mLiveClassID = intent.getIntExtra(Constants.CLASS_ID, 0);
mLiveClass.setText(intent.getStringExtra(Constants.CLASS_NAME));
}
};
mLiveTypeCallback = new CommonCallback<LiveRoomTypeBean>() {
@Override
public void callback(LiveRoomTypeBean bean) {
switch (bean.getId()) {
case Constants.LIVE_TYPE_NORMAL:
onLiveTypeNormal(bean);
break;
case Constants.LIVE_TYPE_PWD:
onLiveTypePwd(bean);
break;
case Constants.LIVE_TYPE_PAY:
onLiveTypePay(bean);
break;
case Constants.LIVE_TYPE_TIME:
onLiveTypeTime(bean);
break;
}
}
};
}
@Override
public void onClick(View v) {
if (!canClick()) {
return;
}
int i = v.getId();
if (i == R.id.avatar_group) {
setAvatar();
} else if (i == R.id.btn_camera) {
toggleCamera();
} else if (i == R.id.btn_close) {
close();
} else if (i == R.id.btn_live_class) {
chooseLiveClass();
} else if (i == R.id.btn_beauty) {
beauty();
}else if (i == R.id.btn_wishlist) {
//点击心愿单
openWishListWindow();
} else if (i == R.id.btn_room_type) {
chooseLiveType();
} else if (i == R.id.btn_start_live) {
startLive();
} else if (i == R.id.btn_locaiton) {
switchLocation();
}else if(i == R.id.btn_horizontally){
RCRTCCameraOutputStream cameraStream = RCRTCEngine.getInstance().getDefaultVideoStream();
cameraStream.setPreviewMirror(!cameraStream.isPreviewMirror());
}
}
/**
* 打开心愿单窗口
*/
public void openWishListWindow() {
LiveWishListDialogFragment fragment = new LiveWishListDialogFragment();
if (mContext instanceof LiveRyAnchorActivity){
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY");
}
}
/**
* 打开 关闭位置
*/
private void switchLocation() {
if (mOpenLocation) {
new DialogUitl.Builder(mContext)
.setContent(mContext.getString(R.string.live_location_close_3))
.setCancelable(true)
.setConfirmString(mContext.getString(R.string.live_location_close_2))
.setClickCallback(new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
toggleLocation();
}
})
.build()
.show();
} else {
toggleLocation();
}
}
private void toggleLocation() {
mOpenLocation = !mOpenLocation;
if (mLocationImg != null) {
mLocationImg.setImageResource(mOpenLocation ? R.mipmap.address_choice : R.mipmap.icon_live_ready_location_0);
}
if (mCity != null) {
mCity.setText(mOpenLocation ? CommonAppConfig.getInstance().getCity() :mContext.getString(R.string.live_location_close));
}
}
/**
* 设置头像
*/
private void setAvatar() {
if (mLiveSdk == Constants.LIVE_SDK_TX) {
mImageUtil.getImageByAlbum();
} else {
DialogUitl.showStringArrayDialog(mContext, new Integer[]{
R.string.camera, R.string.alumb}, new DialogUitl.StringArrayDialogCallback() {
@Override
public void onItemClick(String text, int tag) {
if (tag == R.string.camera) {
mImageUtil.getImageByCamera();
} else {
mImageUtil.getImageByAlbum();
}
}
});
}
}
/**
* 切换镜头
*/
private void toggleCamera() {
((LiveRyAnchorActivity) mContext).toggleCamera();
}
/**
* 关闭
*/
private void close() {
((LiveRyAnchorActivity) mContext).endLives();
}
/**
* 选择直播频道
*/
private void chooseLiveClass() {
try {
Intent intent = new Intent(mContext, LiveChooseClassActivity.class);
intent.putExtra(Constants.CLASS_ID, mLiveClassID);
mImageUtil.startActivityForResult(intent, mActivityResultCallback);
}catch (Exception e){
}
}
/**
* 设置美颜
*/
private void beauty() {
((LiveRyAnchorActivity) mContext).beauty();
// Intent intent = new Intent(mContext, Beauty360Activity3.class);
// mContext.startActivity(intent);
}
/**
* 选择直播类型
*/
private void chooseLiveType() {
Bundle bundle = new Bundle();
bundle.putInt(Constants.CHECKED_ID, mLiveType);
LiveRoomTypeDialogFragment fragment = new LiveRoomTypeDialogFragment();
fragment.setArguments(bundle);
fragment.setCallback(mLiveTypeCallback);
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
}
/**
* 普通房间
*/
private void onLiveTypeNormal(LiveRoomTypeBean bean) {
mLiveType = bean.getId();
mLiveTypeTextView.setText(bean.getName());
mLiveTypeVal = 0;
mLiveTimeCoin = 0;
}
/**
* 密码房间
*/
private void onLiveTypePwd(final LiveRoomTypeBean bean) {
DialogUitl.showSimpleInputDialog(mContext,mContext.getString(R.string.live_set_pwd), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, 8, new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
if (TextUtils.isEmpty(content)) {
ToastUtil.show(mContext.getString(R.string.live_set_pwd_empty));
} else {
mLiveType = bean.getId();
mLiveTypeTextView.setText(bean.getName());
if (StringUtil.isInt(content)) {
mLiveTypeVal = Integer.parseInt(content);
}
mLiveTimeCoin = 0;
dialog.dismiss();
}
}
});
}
/**
* 付费房间
*/
private void onLiveTypePay(final LiveRoomTypeBean bean) {
DialogUitl.showSimpleInputDialog(mContext,mContext.getString(R.string.live_set_fee), DialogUitl.INPUT_TYPE_NUMBER, 8, new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
if (TextUtils.isEmpty(content)) {
ToastUtil.show(mContext.getString(R.string.live_set_fee_empty));
} else {
mLiveType = bean.getId();
mLiveTypeTextView.setText(bean.getName());
if (StringUtil.isInt(content)) {
mLiveTypeVal = Integer.parseInt(content);
}
mLiveTimeCoin = 0;
dialog.dismiss();
}
}
});
}
/**
* 计时房间
*/
private void onLiveTypeTime(final LiveRoomTypeBean bean) {
LiveTimeDialogFragment fragment = new LiveTimeDialogFragment();
Bundle bundle = new Bundle();
bundle.putInt(Constants.CHECKED_COIN, mLiveTimeCoin);
fragment.setArguments(bundle);
fragment.setCommonCallback(new CommonCallback<Integer>() {
@Override
public void callback(Integer coin) {
mLiveType = bean.getId();
mLiveTypeTextView.setText(bean.getName());
mLiveTypeVal = coin;
mLiveTimeCoin = coin;
}
});
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveTimeDialogFragment");
}
public void hide() {
if (mContentView != null && mContentView.getVisibility() == View.VISIBLE) {
mContentView.setVisibility(View.INVISIBLE);
}
}
public void show() {
if (mContentView != null && mContentView.getVisibility() != View.VISIBLE) {
mContentView.setVisibility(View.VISIBLE);
}
}
/**
* 点击开始直播按钮
*/
private void startLive() {
boolean startPreview = ((LiveRyAnchorActivity) mContext).isStartPreview();
// if (!startPreview) {
// ToastUtil.show(R.string.please_wait);
// return;
// }
if (mLiveClassID == 0) {
ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
return;
}
if (mLiveShareAdapter != null) {
String type = mLiveShareAdapter.getShareType();
if (!TextUtils.isEmpty(type)) {
// ((LiveActivity) mContext).shareLive(type, new MobCallback() {
// @Override
// public void onSuccess(Object data) {
//
// }
//
// @Override
// public void onError() {
//
// }
//
// @Override
// public void onCancel() {
//
// }
//
// @Override
// public void onFinish() {
// createRoom();
// }
// });
} else {
createRoom();
}
} else {
createRoom();
}
}
/**
* 请求创建直播间接口开始直播
*/
boolean isHttpBack = false;
private void createRoom() {
if(isHttpBack == false) {
isHttpBack = true;
if (mLiveClassID == 0) {
ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
return;
}
String title = mEditTitle.getText().toString().trim();
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile,0, false,new HttpCallback() {
@Override
public void onSuccess(int code, String msg, final String[] info) {
if (code == 0 && info.length > 0) {
L.e("开播", "createRoom------->" + info[0]);
isHttpBack = false;
final CommonAppConfig appConfig = CommonAppConfig.getInstance();
UserBean u = appConfig.getUserBean();
((LiveRyAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
//
// RongChatRoomClient.getInstance().joinChatRoom("g" + appConfig.getUid(), -1, new IRongCoreCallback.OperationCallback() {
// @Override
// public void onSuccess() {
// Log.i("tx","创建成功");
// ((LiveAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
// }
//
// @Override
// public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
// Log.i("tx",code+"创建失败"+coreErrorCode);
// if(code == 10025){
// ((LiveAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
// }else{
// ToastUtil.show("开播失败,联系客服。");
// }
// }
// });
} else {
ToastUtil.show(msg);
}
}
@Override
public void onError() {
super.onError();
isHttpBack = false;
}
});
}else {
ToastUtil.show("請求中,請勿重複點擊");
}
}
public void release() {
mImageUtil = null;
mActivityResultCallback = null;
mLiveTypeCallback = null;
}
@Override
public void onDestroy() {
LiveHttpUtil.cancel(LiveHttpConsts.CREATE_ROOM);
}
}

View File

@ -54,8 +54,6 @@ import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
@ -69,7 +67,6 @@ import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yunbao.common.bean.PrankProgressBean;
import com.yunbao.common.fragment.GiftWallMainTab1Fragment;
import com.yunbao.common.utils.DebugUtils;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.MobclickAgent;
@ -130,12 +127,10 @@ import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.NewLevelManager;
import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RouteUtil;
@ -158,10 +153,8 @@ import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.adapter.ComboAdapter;
import com.yunbao.live.adapter.LiveChatAdapter;
import com.yunbao.live.adapter.LiveRoomFastMessageRecyclerViewAdapter;
import com.yunbao.live.adapter.LiveUserAdapter;
@ -203,7 +196,6 @@ import com.yunbao.live.presenter.LiveLightAnimPresenter;
import com.yunbao.live.utils.LiveRoomVoteManager;
import com.yunbao.live.utils.LiveTextRender;
import com.yunbao.live.utils.LoadDian9TuUtil;
import com.yunbao.live.utils.ZeusKt;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@ -226,8 +218,6 @@ import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.UserInfo;
import com.bumptech.glide.load.resource.gif.GifDrawable;
import pl.droidsonroids.gif.GifImageView;
/**
@ -1365,7 +1355,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
topBanner1 = (Banner) findViewById(R.id.top_banner1);
topBanner2 = (Banner) findViewById(R.id.top_banner2);
if (LivePushTxViewHolder.mTRTCCloud != null || LivePushSwViewHolder.rtcRoom != null) {
if (LivePushTxViewHolder.mTRTCCloud != null ) {
fans_btn.setVisibility(View.GONE);
}
mPkRankTopIcon.setVisibility(View.GONE);
@ -1456,8 +1446,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
liveHDDialogFragment.setArguments(bundle1);
if(mContext instanceof LiveAudienceActivity){
liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}else if(mContext instanceof LiveRyAnchorActivity){
liveHDDialogFragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}else if(mContext instanceof LiveSwAnchorActivity){
liveHDDialogFragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
@ -1474,14 +1462,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
});
fragment.setmLiveUid(mLiveUid);
if(mContext instanceof LiveRyAnchorActivity){
fragment.show(((LiveRyAnchorActivity)mContext).getSupportFragmentManager(), "LivePrankDialogFragment");
}else if(mContext instanceof LiveSwAnchorActivity){
if(mContext instanceof LiveSwAnchorActivity){
fragment.show(((LiveSwAnchorActivity)mContext).getSupportFragmentManager(), "LivePrankDialogFragment");
}
if(mContext instanceof LiveRyAnchorActivity){
com.yunbao.live.activity.LiveRyAnchorActivity.mLiveAnchorViewHolder.closeMenuRed();
}else if(mContext instanceof LiveSwAnchorActivity){
if(mContext instanceof LiveSwAnchorActivity){
com.yunbao.live.activity.LiveSwAnchorActivity.mLiveAnchorViewHolder.closeMenuRed();
}
}else{
@ -1707,7 +1691,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
findViewById(R.id.btn_follow).setVisibility(View.GONE);
findViewById(R.id.live_rank_pk).setVisibility(View.GONE);
}
if (mContext instanceof LiveRyAnchorActivity ||mContext instanceof LiveSwAnchorActivity) {
if (mContext instanceof LiveSwAnchorActivity) {
findViewById(R.id.open_sidebar).setVisibility(View.GONE);
findViewById(R.id.btn_follow).setVisibility(View.GONE);
findViewById(R.id.live_rank_pk).setVisibility(View.GONE);
@ -2188,7 +2172,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
layoutParams.topMargin = DpUtil.dp2px(240);
dragonImmediateParticipation.setLayoutParams(layoutParams);
}
if (dragonImmediateParticipationTime.getVisibility() == View.VISIBLE && mContext instanceof LiveRyAnchorActivity || mContext instanceof LiveSwAnchorActivity) {
if (dragonImmediateParticipationTime.getVisibility() == View.VISIBLE && mContext instanceof LiveSwAnchorActivity) {
RelativeLayout.LayoutParams layoutParamsredPacket = (RelativeLayout.LayoutParams) redPacket.getLayoutParams();
layoutParamsredPacket.topMargin = DpUtil.dp2px(160);
redPacket.setLayoutParams(layoutParamsredPacket);
@ -2197,7 +2181,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
layoutParams.topMargin = DpUtil.dp2px(240);
dragonImmediateParticipationTime.setLayoutParams(layoutParams);
}
if (mContext instanceof LiveRyAnchorActivity || mContext instanceof LiveSwAnchorActivity) {
if (mContext instanceof LiveSwAnchorActivity) {
if (dragonImmediateParticipationTime.getVisibility() == View.GONE) {
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) redPacket.getLayoutParams();
layoutParams.topMargin = DpUtil.dp2px(160);
@ -2220,7 +2204,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
redSchedule.setText(stringBuffer.toString());
openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketCount() + ""));
}
if (IMLoginManager.get(mContext).getUserInfo().anchorUserType() && (mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity)) {
if (IMLoginManager.get(mContext).getUserInfo().anchorUserType() && (mContext instanceof LiveSwAnchorActivity )) {
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
anchorTimeHandler.post(anchorTimeRunnable);
}
@ -2232,7 +2216,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Override
public void onViewClicks() {
if (!(mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity)) {
if (!(mContext instanceof LiveSwAnchorActivity )) {
LiveNetManager.get(mContext).redPacketInfo(mLiveUid, redPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback<RedPacketInfoModel>() {
@Override
public void onSuccess(RedPacketInfoModel data) {
@ -2359,7 +2343,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (d_pk_view != null) {
d_pk_view.setVisibility(View.GONE);
}
if (LivePushTxViewHolder.mTRTCCloud != null || LivePushSwViewHolder.rtcRoom != null) {
if (LivePushTxViewHolder.mTRTCCloud != null ) {
fans_btn.setVisibility(View.GONE);
}
mRedVal.setVisibility(View.GONE);
@ -3429,7 +3413,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
bundle.putString("toUid", toUid);
bundle.putInt("isAttention", isAttention);
bundle.putBoolean("isLive", isAnchor);
bundle.putBoolean("SBW", !(mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity));
bundle.putBoolean("SBW", !(mContext instanceof LiveSwAnchorActivity ));
giftWallDialog.setArguments(bundle);
giftWallDialog.show(((AbsActivity) mContext).getSupportFragmentManager(), "GiftWallDialog");
@ -3795,7 +3779,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
//直播间 粉丝排行榜
openMedalRankWindow();
} else if (i == R.id.btn_guard) {
((LiveActivity) mContext).openNewGuardListWindow((mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity));
((LiveActivity) mContext).openNewGuardListWindow((mContext instanceof LiveSwAnchorActivity));
} else if (i == R.id.btn_red_pack) {
((LiveActivity) mContext).openRedPackListWindow();
@ -3803,13 +3787,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
((LiveActivity) mContext).openPrizePoolWindow();
} else if (i == R.id.user_more) {
MobclickAgent.onEvent(mContext, "live_room_audience_list", "直播间上面点观众列表按钮");
((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity);
((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity);
} else if (i == R.id.hot_btn) {
((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity);
((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity );
} else if (i == R.id.noble_seat) {
MobclickAgent.onEvent(mContext, "live_room_noble", "贵族按钮");
((LiveActivity) mContext).openUserMoreListWindow(1, false, true, mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity);
((LiveActivity) mContext).openUserMoreListWindow(1, false, true, mContext instanceof LiveSwAnchorActivity );
} else if (i == R.id.btn_close) {
// if (sudGameMin!=null&&sudGameMin.getVisibility()==View.VISIBLE) {
// new XPopup.Builder(mContext)
@ -3842,7 +3826,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} else if (i == R.id.user_guard) {
MobclickAgent.onEvent(mContext, "anchor_avatar_guard", "守护按钮");
// ((LiveActivity) mContext).openUserMoreListWindow(2, true);
((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity);
((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveSwAnchorActivity );
}
if (i == R.id.lt_trickery) {
showTrickeryDialog();
@ -3867,7 +3851,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
* @param in 展示的view
*/
private void changeMsgView(View out, View in) {
if (mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity) {
if (mContext instanceof LiveSwAnchorActivity ) {
return;
}
if (in.getVisibility() == View.VISIBLE) {
@ -4098,24 +4082,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
}
} else if (mContext instanceof LiveRyAnchorActivity) {
if (forAct == 1) {
//是否关注0==没关注
if (isAttention == 0) {
if (isStayRoomfive) {
showFollowDialog(mNameText, mAvatarUrl, mContext);
} else {
LiveRyAnchorActivity.backIndex = 1;
((LiveRyAnchorActivity) mContext).onBackPressed();
}
} else {
LiveRyAnchorActivity.backIndex = 1;
((LiveRyAnchorActivity) mContext).onBackPressed();
}
} else {
LiveRyAnchorActivity.backIndex = 1;
((LiveRyAnchorActivity) mContext).onBackPressed();
}
}
}
@ -5241,7 +5207,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
lt_trickster_salvation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mContext instanceof LiveSwAnchorActivity || mContext instanceof LiveRyAnchorActivity) {
if (mContext instanceof LiveSwAnchorActivity) {
dialog.dismiss();
return;
}

View File

@ -46,7 +46,6 @@ import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.bean.WishlistModel;
@ -222,8 +221,6 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
if (PKing == false) {
if (isSw) {
((LiveSwAnchorActivity) mContext).openLinkMicAnchorWindow(true);
} else {
((LiveRyAnchorActivity) mContext).openLinkMicAnchorWindow(true);
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
@ -300,8 +297,6 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
private void close() {
if (isSw) {
((LiveSwAnchorActivity) mContext).closeLive();
} else {
((LiveRyAnchorActivity) mContext).closeLive();
}
}
@ -320,8 +315,6 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
}
if (isSw) {
((LiveSwAnchorActivity) mContext).showFunctionDialog();
} else {
((LiveRyAnchorActivity) mContext).showFunctionDialog();
}
}
@ -357,8 +350,6 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
private void applyLinkMicPk() {
if (isSw) {
((LiveSwAnchorActivity) mContext).applyLinkMicPk();
} else {
((LiveRyAnchorActivity) mContext).applyLinkMicPk();
}
}

View File

@ -15,7 +15,6 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
@ -28,10 +27,8 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.lzf.easyfloat.EasyFloat;
import com.lzf.easyfloat.enums.ShowPattern;
import com.lzf.easyfloat.permission.PermissionUtils;
import com.lzf.easyfloat.utils.LifecycleUtils;
import com.yunbao.common.dialog.DebugDialog;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.DebugUtils;
import com.yunbao.common.utils.MobclickAgent;
@ -76,7 +73,6 @@ import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.OpenAdManager;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.L;
@ -109,27 +105,20 @@ import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.event.LiveOpenSuccessEvent;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPresenter;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
import com.yunbao.live.presenter.LiveSwLinkMicPkPresenter;
import com.yunbao.live.socket.SocketClient;
import com.yunbao.live.socket.SocketMessageListener;
import com.yunbao.live.socket.SocketRyChatUtil;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.socket.SocketSwChatUtil;
import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.socket.SocketSendBean;
import com.yunbao.live.utils.LiveImDeletUtil;
import com.yunbao.live.utils.LiveTextRender;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.LiveFloatView;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.rong.imlib.IRongCallback;
@ -181,7 +170,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//主播与主播PK逻辑
private LiveSwLinkMicPkPresenter mLiveSwLinkMicPkPresenter;
private LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;
// private LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;
//直播间的类型 普通 密码 门票 计时等
@ -191,7 +180,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//直播结束页面
private LiveEndViewHolder mLiveEndViewHolder;
private SocketSwClient mSocketSwClient;
private SocketRyClient mSocketRyClient;
// private SocketRyClient mSocketRyClient;
private SocketClient mSocketClient;
private String mDanmuPrice;//弹幕价格
@ -368,11 +357,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public void run() {
try {
Log.e("ImgLoader1", data.getAvatar());
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.clearData();
mLiveRyLinkMicPkPresenter.release();
mLiveRyLinkMicPkPresenter = null;
}
if (mLiveSwLinkMicPkPresenter != null) {
mLiveSwLinkMicPkPresenter.clearData();
@ -400,7 +384,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (isSw) {
mLivePlayViewHolder = new LivePlaySwViewHolder(mContext, playContainer, mLiveBean.getLandscape());
} else {
mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1);
// mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1);
}
mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager(), isSw);
@ -411,8 +395,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveSwLinkMicPkPresenter = new LiveSwLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
mLiveSwLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
} else {
mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
mLiveRyLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
// mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
// mLiveRyLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
}
mLivePlayViewHolder.initSwEngine(mLiveBean.getUid());
mLivePlayViewHolder.addToParent();
@ -440,16 +424,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveSwLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
}
} else {
if (mLiveRyLinkMicPkPresenter == null) {
mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
mLiveRyLinkMicPkPresenter.setmLiveRoomViewHolder(mLiveRoomViewHolder);
}
}
//去除主播离开画面
if (LivePlayRyViewHolder.leave != null) {
/* if (LivePlayRyViewHolder.leave != null) {
LivePlayRyViewHolder.leave.setVisibility(View.GONE);
}
}*/
if (LivePlaySwViewHolder.leave != null) {
LivePlaySwViewHolder.leave.setVisibility(View.GONE);
}
@ -489,13 +469,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (isSw) {
mLiveSwLinkMicPkPresenter.setLiveUid(data.getUid(), "");
} else {
mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), "");
// mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), "");
}
if (isSw) {
mSocketSwClient = new SocketSwClient(mLiveBean.getUid(), PortraitLiveManager.this, mContext);
} else {
mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this, mContext);
// mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this, mContext);
}
if (mLiveLinkMicPresenter != null) {
mLiveLinkMicPresenter.setSocketClient(mSocketClient);
@ -676,9 +656,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (LivePlaySwViewHolder.leave != null) {
LivePlaySwViewHolder.leave.setVisibility(View.VISIBLE);
}
if (LivePlayRyViewHolder.leave != null) {
LivePlayRyViewHolder.leave.setVisibility(View.VISIBLE);
}
}
//判断是否有连麦要显示连麦窗口
String linkMicUid = data.getEnterRoomInfo().getLinkmicUid();
@ -757,7 +734,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (isSw) {
mLiveSwLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean);
} else {
mLiveRyLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean);
// mLiveRyLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean);
}
isShowPrank = false;
} else if (!pkInfo.getString("end_pk_time").equals("0")) {
@ -776,7 +753,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (isSw) {
mLiveSwLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean);
} else {
mLiveRyLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean);
// mLiveRyLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean);
}
isShowPrank = false;
} else {
@ -949,10 +926,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.clearData();
mLiveRoomViewHolder.countDownTimerTrickery = null;
}
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.clearData();
mLiveRyLinkMicPkPresenter.release();
}
if (mLiveSwLinkMicPkPresenter != null) {
mLiveSwLinkMicPkPresenter.clearData();
mLiveSwLinkMicPkPresenter.release();
@ -962,7 +935,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder = null;
mLiveLinkMicPresenter = null;
mLiveLinkMicAnchorPresenter = null;
mLiveRyLinkMicPkPresenter = null;
mLiveSwLinkMicPkPresenter = null;
mLivePlayViewHolder = null;
}
@ -990,10 +962,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.cancelAllAnim();
}
//断开socket
if (mSocketRyClient != null) {
mSocketRyClient.disConnect();
mSocketRyClient = null;
}
if (mSocketSwClient != null) {
mSocketSwClient.disConnect();
mSocketSwClient = null;
@ -1010,11 +978,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveLinkMicAnchorPresenter.clearData();
mLiveLinkMicAnchorPresenter.release();
}
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.clearData();
mLiveRyLinkMicPkPresenter.release();
mLiveRyLinkMicPkPresenter = null;
}
if (mLiveSwLinkMicPkPresenter != null) {
mLiveSwLinkMicPkPresenter.clearData();
mLiveSwLinkMicPkPresenter.release();
@ -1048,7 +1011,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder = null;
mLiveLinkMicPresenter = null;
mLiveLinkMicAnchorPresenter = null;
mLiveRyLinkMicPkPresenter = null;
if (PermissionUtils.checkPermission(mContext) && !kick) {
LiveFloatView.getInstance()
.cacheLiveData(mLiveBean, mLiveType, isSw, mLiveTypeVal)
@ -1218,16 +1180,16 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
} else {
if (RCRTCEngine.getInstance().getRoom() == null || RCRTCEngine.getInstance().getRoom().getLocalUser() == null) {
/* if (RCRTCEngine.getInstance().getRoom() == null || RCRTCEngine.getInstance().getRoom().getLocalUser() == null) {
return;
}
ToastUtil.show("下麥中,稍等.....");
RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() {
/**
*//**
* 当切换失败且SDK处于无法回退状态时回调该角色已经无法使用当前角色继续进行音视频
* SDK内部会退出房间并清理所有资源该用户只能重新加入房间才能继续音视频
*/
*//*
@Override
public void onKicked() {
@ -1270,16 +1232,16 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
/**
*//**
* 当切换失败且不影响当前角色继续音视频时回调
* @param errorCode 失败错误码
*/
*//*
@Override
public void onFailed(RTCErrorCode errorCode) {
Log.e("ry", "下麦失败" + errorCode);
}
});
});*/
}
}
@ -1526,9 +1488,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveSwLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
}
} else {
if (mLiveRyLinkMicPkPresenter != null) {
/* if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
}
}*/
}
}
@ -1543,13 +1505,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
} else {
if (mLiveRyLinkMicPkPresenter != null) {
/*if (mLiveRyLinkMicPkPresenter != null) {
if (mLiveUid.equals(leftUid + "")) {
mLiveRyLinkMicPkPresenter.onPkProgressEnd(left, right, bean);
} else {
mLiveRyLinkMicPkPresenter.onPkProgressEnd(right, left, bean);
}
}
}*/
}
}
@ -1809,11 +1771,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);//3秒后执行Runnable中的run方法
}
} else {
if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
/* if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = true;
mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);//3秒后执行Runnable中的run方法
}
}*/
}
if (mLivePlayViewHolder != null) {
@ -1846,12 +1808,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
} else {
if (mLiveRyLinkMicPkPresenter != null) {
/* if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkClose(i);
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.resetViewGone();
}
}
}*/
}
if (mLiveRoomViewHolder != null) {
mLivePlayViewHolder.setLiveBeanLandscape(landscape);
@ -1885,10 +1847,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//mLiveRoomViewHolder.setDelOtherInfo();
}
} else {
if (mLiveRyLinkMicPkPresenter != null) {
/* if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkEnd(winUid);
//mLiveRoomViewHolder.setDelOtherInfo();
}
}*/
}
}
@ -2086,11 +2048,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mEnd = true;
//断开socket
if (mSocketRyClient != null) {
mSocketRyClient.disConnect();
mSocketRyClient = null;
}
if (mSocketSwClient != null) {
mSocketSwClient.disConnect();
mSocketSwClient = null;

View File

@ -155,8 +155,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import cn.rongcloud.rtc.api.RCRTCConfig;
import cn.rongcloud.rtc.api.RCRTCEngine;
import io.agora.beautyapi.faceunity.agora.LiveFloatView;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.reactivex.Observer;
@ -280,10 +278,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
Height = mDisplay.getHeight();
// IMLib 初始化
RongIMClient.init(this, RongcloudIMManager.RONG_IM_KEY, true);
// RTCLib 初始化
RCRTCConfig.Builder config = RCRTCConfig.Builder.create();
config.enableEncoderTexture(false);//新娱美颜 需要关闭这个
RCRTCEngine.getInstance().init(MainActivity.this, config.build());
//推送跳直播间
if (getIntent().getStringExtra("liveid") != null) {
LiveHttpUtil.getLiveInfo(getIntent().getStringExtra("liveid") + "", new HttpCallback() {

View File

@ -53,7 +53,6 @@ import java.io.File;
import java.util.Arrays;
import java.util.List;
import cn.rongcloud.rtc.api.RCRTCEngine;
import io.rong.imlib.RongIMClient;
/**
@ -354,7 +353,6 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener<
private void logout() {
IMLoginManager.get(this).logout(this);
CommonAppConfig.getInstance().clearLoginInfo();
RCRTCEngine.getInstance().unInit();
RongIMClient.getInstance().logout();
Intent intent = new Intent(SettingActivity.this, EntryActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

View File

@ -38,7 +38,6 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.LiveConfig;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.bean.LiveKsyConfigBean;
import com.yunbao.main.R;
@ -246,8 +245,6 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O
try {
if (code == 201) { //声网
LiveSwAnchorActivity.forward(mContext, Constants.LIVE_SDK_SW, JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class));
} else if (code == 200) {//融云
LiveRyAnchorActivity.forward(mContext, obj.getIntValue("live_sdk"), JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class));
}
} catch (Exception e) {