fix[声望升级-秒开]

This commit is contained in:
Martin 2024-06-01 11:16:26 +08:00
parent ce9336737f
commit 19c270ad22
7 changed files with 63 additions and 26 deletions

View File

@ -98,16 +98,18 @@ public class SWAuManager extends BaseCacheManager {
*/
public void initRtcEngine(Activity mContext) {
this.mContext = mContext;
try {
// 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
} catch (Exception e) {
throw new RuntimeException("Check the error.");
if(mRtcEngine==null){
try {
// 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
} catch (Exception e) {
throw new RuntimeException("Check the error.");
}
}
mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING); // 直播模式引擎級別
// 开启本地预览
@ -120,13 +122,15 @@ public class SWAuManager extends BaseCacheManager {
public void initRtcEngineAudio(Activity mContext) {
this.mContext = mContext;
try {
if(mRtcEngine==null){
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
}
// 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
mRtcEngine.enableAudio();
mRtcEngine.enableLocalAudio(true);
} catch (Exception e) {
@ -417,7 +421,9 @@ public class SWAuManager extends BaseCacheManager {
}
public void preloadChannel(List<LiveBean> uids){
L.eSw("设置秒开数据");
for (int i = 0; i <uids.size(); i++) {
L.eSw("设置秒开数据 uid"+uids.get(i).getUid()+" --- userName:"+uids.get(i).getUserNiceName());
mRtcEngine.preloadChannel(CommonAppConfig.SWToken,getChannelName(uids.get(i).getUid()),Integer.parseInt(CommonAppConfig.getInstance().getUid()));
}
}

View File

@ -91,13 +91,16 @@ public class SWManager extends BaseCacheManager {
uid = Integer.parseInt(strUid);
}
try {
// 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
if(mRtcEngine==null){
// 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mRtcEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
}
} catch (Exception e) {
throw new RuntimeException("Check the error.");
}

View File

@ -144,6 +144,7 @@ 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;
import io.reactivex.disposables.Disposable;
import io.rong.imkit.config.RongConfigCenter;
@ -219,6 +220,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override
protected void main() {
//初始化声网
SWAuManager.get().initRtcEngine(this);
ActivityCompat.postponeEnterTransition(this);
ConversationIMListManager.get(this);
OpenAdManager.getInstance();

View File

@ -15,6 +15,7 @@ import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.custom.ItemDecoration;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.main.R;
@ -32,6 +33,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener<LiveBean> {
private CommonRefreshView mRefreshView;
private MainHomeRemFollLiveAdapter mAdapter;
@ -56,7 +59,7 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
mRefreshView.showRefreshBar();
mRefreshView.mRecyclerView.scrollToPosition(0);
}
}else if ("blacklist".equals(str)) {
} else if ("blacklist".equals(str)) {
if (mRefreshView != null) {
mRefreshView.showRefreshBar();
}
@ -99,6 +102,7 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
@Override
public void onRefreshSuccess(List<LiveBean> list, int count) {
SWAuManager.get().preloadChannel(list);
EventBus.getDefault().post(new AnchorRecommendModel());
}
@ -115,6 +119,7 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
new_data.add(loadItemList.get(j));
}
}
SWAuManager.get().preloadChannel(new_data);
mAdapter.insertList(new_data);
}
@ -147,6 +152,9 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
// if (mRefreshView != null) {
// mRefreshView.initData();
// }
if (mAdapter != null) {
SWAuManager.get().preloadChannel(mAdapter.getList());
}
}
@Override
@ -164,6 +172,6 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
@Override
public void onResume() {
super.onResume();
L.eSw("onResume");
}
}

View File

@ -23,6 +23,8 @@ import com.yunbao.main.http.MainHttpUtil;
import java.util.List;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
/**
* Created by cxf on 2018/9/22.
* 首页 关注
@ -70,7 +72,9 @@ public class MainHomeFollowViewHolder extends AbsMainHomeChildViewHolder impleme
public List<LiveBean> processData(String[] info) {
if (info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
return JSON.parseArray(obj.getString("list"), LiveBean.class);
List<LiveBean> liveBeanList = JSON.parseArray(obj.getString("list"), LiveBean.class);
SWAuManager.get().preloadChannel(liveBeanList);
return liveBeanList;
}
return null;
}

View File

@ -74,6 +74,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
/**
* Created by cxf on 2018/9/22.
* MainActivity 首页 直播
@ -242,6 +244,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
if (liveModel != null) {
old_data.remove(liveModel);
}
SWAuManager.get().preloadChannel(old_data);
new_data.addAll(old_data);
}
@ -271,6 +274,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
}
}
if (loadItemList.size() > 0) {
SWAuManager.get().preloadChannel(new_data);
mAdapter.insertList(new_data);
}
}
@ -533,6 +537,9 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
@Override
public void loadData() {
if (mAdapter != null) {
SWAuManager.get().preloadChannel(mAdapter.getList());
}
}
@Override

View File

@ -31,6 +31,8 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.Arrays;
import java.util.List;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
/**
* 首页推荐
*/
@ -104,6 +106,7 @@ public class MainHomeRecomLiveViewHolder extends AbsMainHomeChildViewHolder impl
@Override
public void onRefreshSuccess(List<LiveBean> list, int count) {
SWAuManager.get().preloadChannel(list);
EventBus.getDefault().post(new AnchorRecommendModel());
}
@ -149,6 +152,9 @@ public class MainHomeRecomLiveViewHolder extends AbsMainHomeChildViewHolder impl
// if (mRefreshView != null) {
// mRefreshView.initData();
// }
if (mAdapter != null) {
SWAuManager.get().preloadChannel(mAdapter.getList());
}
}
@Override