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) { public void initRtcEngine(Activity mContext) {
this.mContext = mContext; this.mContext = mContext;
try { if(mRtcEngine==null){
// 创建 RtcEngineConfig 对象并进行配置 try {
RtcEngineConfig config = new RtcEngineConfig(); // 创建 RtcEngineConfig 对象并进行配置
config.mContext = mContext; RtcEngineConfig config = new RtcEngineConfig();
config.mAppId = CommonAppConfig.SWAPPId; config.mContext = mContext;
config.mEventHandler = mRtcEventHandler; config.mAppId = CommonAppConfig.SWAPPId;
// 创建并初始化 RtcEngine config.mEventHandler = mRtcEventHandler;
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config); // 创建并初始化 RtcEngine
} catch (Exception e) { mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
throw new RuntimeException("Check the error."); } catch (Exception e) {
throw new RuntimeException("Check the error.");
}
} }
mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING); // 直播模式引擎級別 mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING); // 直播模式引擎級別
// 开启本地预览 // 开启本地预览
@ -120,13 +122,15 @@ public class SWAuManager extends BaseCacheManager {
public void initRtcEngineAudio(Activity mContext) { public void initRtcEngineAudio(Activity mContext) {
this.mContext = mContext; this.mContext = mContext;
try { 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 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = CommonAppConfig.SWAPPId;
config.mEventHandler = mEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
mRtcEngine.enableAudio(); mRtcEngine.enableAudio();
mRtcEngine.enableLocalAudio(true); mRtcEngine.enableLocalAudio(true);
} catch (Exception e) { } catch (Exception e) {
@ -417,7 +421,9 @@ public class SWAuManager extends BaseCacheManager {
} }
public void preloadChannel(List<LiveBean> uids){ public void preloadChannel(List<LiveBean> uids){
L.eSw("设置秒开数据");
for (int i = 0; i <uids.size(); i++) { 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())); 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); uid = Integer.parseInt(strUid);
} }
try { try {
// 创建 RtcEngineConfig 对象并进行配置 if(mRtcEngine==null){
RtcEngineConfig config = new RtcEngineConfig(); // 创建 RtcEngineConfig 对象并进行配置
config.mContext = mContext; RtcEngineConfig config = new RtcEngineConfig();
config.mAppId = CommonAppConfig.SWAPPId; config.mContext = mContext;
config.mEventHandler = mRtcEventHandler; config.mAppId = CommonAppConfig.SWAPPId;
// 创建并初始化 RtcEngine config.mEventHandler = mRtcEventHandler;
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config); // 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
}
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Check the error."); 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.RCRTCConfig;
import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.RCRTCEngine;
import io.agora.beautyapi.faceunity.agora.LiveFloatView; import io.agora.beautyapi.faceunity.agora.LiveFloatView;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.reactivex.Observer; import io.reactivex.Observer;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.rong.imkit.config.RongConfigCenter; import io.rong.imkit.config.RongConfigCenter;
@ -219,6 +220,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override @Override
protected void main() { protected void main() {
//初始化声网
SWAuManager.get().initRtcEngine(this);
ActivityCompat.postponeEnterTransition(this); ActivityCompat.postponeEnterTransition(this);
ConversationIMListManager.get(this); ConversationIMListManager.get(this);
OpenAdManager.getInstance(); OpenAdManager.getInstance();

View File

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

View File

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

View File

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

View File

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