update 随机PK
This commit is contained in:
parent
29ddc68870
commit
e134ef8d54
@ -83,6 +83,9 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
|
||||
}
|
||||
|
||||
public static Activity getTopActivity() {
|
||||
return activityWeakReference.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
|
@ -146,6 +146,7 @@ public class Constants {
|
||||
public static final String SOCKET_ALL_SERVER_NOTIFY = "AllServerNotify";//全服通知
|
||||
public static final String SOCKET_SEND_BARRAGE = "SendBarrage";//发弹幕
|
||||
public static final String SOCKET_LIVE_DRPK = "LiveDRPK";//多人PK
|
||||
public static final String SOCKET_LIVE_DRPK_RANDOM = "LiveRandomPK";//多人PK
|
||||
public static final String SOCKET_LEAVE_ROOM = "disconnect";//用户离开房间
|
||||
public static final String SOCKET_LIVE_END = "StartEndLive";//主播关闭直播
|
||||
public static final String SOCKET_SYSTEM = "SystemNot";//系统消息
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
|
||||
public class HttpCallbackModel extends BaseModel{
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* 随机PK UserBean
|
||||
*/
|
||||
public class RandomPkUserBean extends UserBean {
|
||||
@SerializedName("is_pk")
|
||||
private int pk;
|
||||
@SerializedName("isattention")
|
||||
private String attention;
|
||||
@SerializedName("user_nicename")
|
||||
private String userNiceName;
|
||||
|
||||
public RandomPkUserBean() {
|
||||
}
|
||||
|
||||
public boolean isPk() {
|
||||
return pk==1;
|
||||
}
|
||||
|
||||
public boolean isAttention() {
|
||||
return attention.equals("1");
|
||||
}
|
||||
|
||||
public String getAttention() {
|
||||
return attention;
|
||||
}
|
||||
|
||||
public void setAttention(String attention) {
|
||||
this.attention = attention;
|
||||
}
|
||||
|
||||
public int getPk() {
|
||||
return pk;
|
||||
}
|
||||
|
||||
public void setPk(int pk) {
|
||||
this.pk = pk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserNiceName() {
|
||||
return userNiceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserNiceName(String userNiceName) {
|
||||
this.userNiceName = userNiceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RandomPkUserBean{" +
|
||||
"pk=" + pk +
|
||||
", attention='" + attention + '\'' +
|
||||
", userNiceName='" + userNiceName + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", userNiceName='" + userNiceName + '\'' +
|
||||
", avatar='" + avatar + '\'' +
|
||||
", avatarThumb='" + avatarThumb + '\'' +
|
||||
", sex=" + sex +
|
||||
", signature='" + signature + '\'' +
|
||||
", coin='" + coin + '\'' +
|
||||
", gold='" + gold + '\'' +
|
||||
", votes='" + votes + '\'' +
|
||||
", consumption='" + consumption + '\'' +
|
||||
", votestotal='" + votestotal + '\'' +
|
||||
", province='" + province + '\'' +
|
||||
", city='" + city + '\'' +
|
||||
", location='" + location + '\'' +
|
||||
", birthday='" + birthday + '\'' +
|
||||
", level=" + level +
|
||||
", levelAnchor=" + levelAnchor +
|
||||
", lives=" + lives +
|
||||
", follows=" + follows +
|
||||
", fans=" + fans +
|
||||
", vip=" + vip +
|
||||
", liang=" + liang +
|
||||
", car=" + car +
|
||||
", medal_level=" + medal_level +
|
||||
", medal_name='" + medal_name + '\'' +
|
||||
", Dress=" + Dress +
|
||||
", noble_id='" + noble_id + '\'' +
|
||||
", yuanbao='" + yuanbao + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
import com.yunbao.common.bean.EnterRoomNewModel;
|
||||
import com.yunbao.common.bean.FaceBookUpModel;
|
||||
import com.yunbao.common.bean.HourRank;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LinkMicUserBeanV2;
|
||||
import com.yunbao.common.bean.LiveInfoModel;
|
||||
@ -18,6 +19,7 @@ import com.yunbao.common.bean.NewPeopleInfo;
|
||||
import com.yunbao.common.bean.NobleRankHideUserListModel;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
import com.yunbao.common.bean.PkRankBean;
|
||||
import com.yunbao.common.bean.RandomPkUserBean;
|
||||
import com.yunbao.common.bean.SearchModel;
|
||||
import com.yunbao.common.bean.SetAttentsModel;
|
||||
import com.yunbao.common.bean.SlideInBannerModel;
|
||||
@ -287,6 +289,7 @@ public interface PDLiveApi {
|
||||
|
||||
/**
|
||||
* 多人连麦-踢出用户
|
||||
*
|
||||
* @param uid 对方uid
|
||||
* @param roomId 当前房间号
|
||||
*/
|
||||
@ -338,4 +341,46 @@ public interface PDLiveApi {
|
||||
@Query("GroupId") String GroupId,
|
||||
@Query("stream") String stream
|
||||
);
|
||||
|
||||
/**
|
||||
* 获取随机PK开关
|
||||
*
|
||||
* @return 1=开,0=关
|
||||
*/
|
||||
@GET("/api/public/?service=Livepk.getRandomPKType")
|
||||
Observable<ResponseModel<List<Integer>>> getRandomPkSwitch();
|
||||
|
||||
/**
|
||||
* 设置随机PK开关
|
||||
* @param pk 1=开,0=关
|
||||
*/
|
||||
@GET("/api/public/?service=Livepk.setRandomPKType")
|
||||
Observable<ResponseModel<List<BaseModel>>> changeRandomPkSwitch(@Query("random_pk") int pk);
|
||||
/**
|
||||
* 获取随机PK次数
|
||||
*/
|
||||
@GET("/api/public/?service=Livepk.getRandomPKType")
|
||||
Observable<ResponseModel<Integer>> getRandomPkNumber();
|
||||
/**
|
||||
* 发起随机PK
|
||||
*/
|
||||
@GET("/api/public/?service=Livepk.setRandomPK")
|
||||
Observable<ResponseModel<String>> randomPK();
|
||||
/**
|
||||
* 随机PK后调用接口给后台记录
|
||||
*/
|
||||
@GET("/api/public/?service=Livepk.startRandomPK")
|
||||
Observable<ResponseModel<BaseModel>> startRandomPK();
|
||||
/**
|
||||
* 自由PK开始后调用接口扣掉次数
|
||||
*/
|
||||
@GET("/api/public/?service=Livepk.setActivePkNum")
|
||||
Observable<ResponseModel<BaseModel>> setRandomPkNum();
|
||||
/**
|
||||
* 随机PK搜索用户
|
||||
* @param cs 简体关键字/uid
|
||||
* @param ct 繁体关键字/uid
|
||||
*/
|
||||
@GET("/api/public/?service=Livepk.searchUser")
|
||||
Observable<ResponseModel<List<RandomPkUserBean>>> randomPkSearchUser(@Query("jian_key")String cs,@Query("fan_key")String ct);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.CheckLiveModel;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
import com.yunbao.common.bean.EnterRoomNewModel;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.LinkMicUserBean;
|
||||
import com.yunbao.common.bean.LinkMicUserBeanV2;
|
||||
import com.yunbao.common.bean.LiveInfoModel;
|
||||
@ -18,6 +19,7 @@ import com.yunbao.common.bean.LiveRoomActivityBanner;
|
||||
import com.yunbao.common.bean.NobleRankHideUserListModel;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
import com.yunbao.common.bean.PkRankBean;
|
||||
import com.yunbao.common.bean.RandomPkUserBean;
|
||||
import com.yunbao.common.bean.SetAttentsModel;
|
||||
import com.yunbao.common.bean.StarChallengeStatusModel;
|
||||
import com.yunbao.common.bean.VipModel;
|
||||
@ -484,6 +486,9 @@ public class LiveNetManager {
|
||||
|
||||
private Disposable randomPkApi;
|
||||
|
||||
/**
|
||||
* PK排位赛接口
|
||||
*/
|
||||
public void getRandomPk(String mLiveUid, String pkUid, HttpCallback<PkRankBean> callback) {
|
||||
randomPkApi = API.get().pdLiveApi(mContext)
|
||||
.getPkRanksList(mLiveUid, pkUid)
|
||||
@ -501,6 +506,192 @@ public class LiveNetManager {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机PK开关
|
||||
* 1=开,0=关
|
||||
*/
|
||||
public void getRandomPkSwitch(HttpCallback<Integer> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.getRandomPkSwitch()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(listResponseModel -> {
|
||||
if (callback != null) {
|
||||
callback.onSuccess(listResponseModel.getData().getInfo().get(0));
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置随机PK开关
|
||||
*
|
||||
* @param pk 1=开,0=关
|
||||
* @param callback @{@link HttpCallbackModel#getCode()} 0=成功
|
||||
*/
|
||||
public void changeRandomPkSwitch(int pk, HttpCallback<HttpCallbackModel> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.changeRandomPkSwitch(pk)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Consumer<ResponseModel<List<BaseModel>>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<List<BaseModel>> responseModel) throws Exception {
|
||||
if (callback != null) {
|
||||
HttpCallbackModel model = new HttpCallbackModel();
|
||||
model.setCode(responseModel.getData().getCode());
|
||||
model.setMsg(responseModel.getData().getMsg());
|
||||
callback.onSuccess(model);
|
||||
}
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机PK次数
|
||||
*/
|
||||
public void getRandomPkNumber(HttpCallback<Integer> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.getRandomPkNumber()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Consumer<ResponseModel<Integer>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<Integer> responseModel) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onSuccess(responseModel.getData().getInfo());
|
||||
}
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起随机PK
|
||||
*/
|
||||
public void randomPK(HttpCallback<String> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.randomPK()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Consumer<ResponseModel<String>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<String> responseModel) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onSuccess("36956");
|
||||
// callback.onSuccess(responseModel.getData().getInfo());
|
||||
}
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
/**
|
||||
* 自由PK开始后调用接口扣掉次数
|
||||
*/
|
||||
public void setRandomPkNum(HttpCallback<HttpCallbackModel> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.setRandomPkNum()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<BaseModel> responseModel) throws Exception {
|
||||
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机PK后调用接口给后台记录
|
||||
*/
|
||||
public void startRandomPK(HttpCallback<Boolean> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.startRandomPK()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<BaseModel> responseModel) throws Exception {
|
||||
if (responseModel.getData().getCode() == 0) {
|
||||
if (callback != null) {
|
||||
callback.onSuccess(true);
|
||||
}
|
||||
} else {
|
||||
callback.onSuccess(false);
|
||||
}
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机PK后调用接口给后台记录
|
||||
* @param cs 简体关键字/uid
|
||||
* @param ct 繁体关键字/uid
|
||||
*/
|
||||
public void randomPkSearchUser(String cs, String ct, HttpCallback<List<RandomPkUserBean>> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.randomPkSearchUser(cs, ct)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Consumer<ResponseModel<List<RandomPkUserBean>>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<List<RandomPkUserBean>> responseModel) throws Exception {
|
||||
if (responseModel.getData().getCode() == 0) {
|
||||
if (callback != null) {
|
||||
callback.onSuccess(responseModel.getData().getInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间取消网络请求
|
||||
*/
|
||||
|
@ -0,0 +1,79 @@
|
||||
package com.yunbao.common.manager;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCRoom;
|
||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
||||
import cn.rongcloud.rtc.base.RTCErrorCode;
|
||||
|
||||
/**
|
||||
* RTC管理类,负责管理申请、同意、拒绝PK
|
||||
*/
|
||||
public class IMRTCManager {
|
||||
private static IMRTCManager manager;
|
||||
private RCRTCRoom rtcRoom;
|
||||
|
||||
private IMRTCManager() {
|
||||
|
||||
}
|
||||
|
||||
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 - 是否将被邀请者音视频资源发送到邀请人房间中合流
|
||||
1:inviteeAutoMix 为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(rtcRoom!=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,callback);
|
||||
}else{
|
||||
callback.onFailed(RTCErrorCode.RongRTCCodeIMError);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import static com.blankj.utilcode.util.SnackbarUtils.dismiss;
|
||||
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE;
|
||||
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_ENABLE;
|
||||
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
|
||||
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK_RANDOM;
|
||||
import static com.yunbao.live.views.AbsRyLivePushViewHolder.mPreView;
|
||||
import static com.yunbao.live.views.LivePushRyViewHolder.dr_pk_view;
|
||||
import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom;
|
||||
@ -50,6 +51,7 @@ import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.IMRTCManager;
|
||||
import com.yunbao.common.utils.BitmapUtil;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DateFormatUtil;
|
||||
@ -88,6 +90,7 @@ import com.yunbao.live.socket.SocketRyChatUtil;
|
||||
import com.yunbao.live.socket.SocketRyClient;
|
||||
import com.yunbao.live.socket.SocketSendBean;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.live.utils.RandomPkManager;
|
||||
import com.yunbao.live.views.LiveEndViewHolder;
|
||||
import com.yunbao.live.views.LiveMusicViewHolder;
|
||||
import com.yunbao.live.views.LiveNewReadyRyViewHolder;
|
||||
@ -152,6 +155,18 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
public static int pk_nub;
|
||||
public static int backIndex = 0;//0=未判断,1=已判断
|
||||
private FaceManager manager;
|
||||
private final RandomPkManager.OnRandomPkTimer onRandomPkTimer = new RandomPkManager.OnRandomPkTimer() {
|
||||
@Override
|
||||
public void onTimer(String time) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartPK(String pkUid) {
|
||||
ToastUtil.show("发起随机PK:"+pkUid);
|
||||
linkDrMicAnchorApply(pkUid, pkUid, SOCKET_LIVE_DRPK_RANDOM);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@ -190,6 +205,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
mContainer = (ViewGroup) findViewById(R.id.container);
|
||||
mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePushViewHolder, true, mContainer);
|
||||
|
||||
RandomPkManager.getInstance().addOnRandomPkTimer(onRandomPkTimer);
|
||||
|
||||
//添加开播前设置控件
|
||||
mLiveReadyViewHolder = new LiveNewReadyRyViewHolder(mContext, mContainer, mLiveSDK);
|
||||
@ -914,6 +930,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
MicStatusManager.getInstance().closeMic(mContext);
|
||||
}
|
||||
L.e("LiveAnchorActivity-------onDestroy------->");
|
||||
RandomPkManager.getInstance().unregisterOnRandomPkTimer(onRandomPkTimer);
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
@ -1081,14 +1098,24 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起多人主播连麦PK申请
|
||||
*
|
||||
* @param pkUid 对方主播的uid
|
||||
* @param stream 对方主播的stream (无需steam)
|
||||
*/
|
||||
public void linkDrMicAnchorApply(String pkUid, String stream) {
|
||||
linkDrMicAnchorApply(pkUid, stream, SOCKET_LIVE_DRPK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起多人主播连麦PK申请
|
||||
*
|
||||
* @param pkUid 对方主播的uid
|
||||
* @param stream 对方主播的stream
|
||||
* @param stream 对方主播的stream (无需steam)
|
||||
* @param extra PK类型
|
||||
*/
|
||||
public void linkDrMicAnchorApply(final String pkUid, String stream) {
|
||||
public void linkDrMicAnchorApply(final String pkUid, String stream, String extra) {
|
||||
|
||||
LiveHttpUtil.livePkCheckLive(pkUid, stream, mStream, new HttpCallback() {
|
||||
@Override
|
||||
@ -1098,10 +1125,12 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
if (obj != null) {
|
||||
if (obj.getString("ispk").equals("0")) {
|
||||
|
||||
rtcRoom.getLocalUser().requestJoinOtherRoom(pkUid, pkUid, true, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() {
|
||||
IMRTCManager.getInstance().requestJoinOtherRoom(pkUid, true, extra, new IRCRTCResultCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (!extra.equals(SOCKET_LIVE_DRPK_RANDOM)) {
|
||||
ToastUtil.show("邀请 " + pkUid + " 发送成功");
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -1384,6 +1413,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查指定直播间连麦人数
|
||||
*
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -14,14 +12,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.RandomPkUserBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.RandomPkBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkBean> {
|
||||
public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
|
||||
private static final int HEAD = 0;
|
||||
private static final int ITEM = 2;
|
||||
|
||||
@ -42,7 +37,7 @@ public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkBean> {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (getItemViewType(position) == ITEM) {
|
||||
((HeadViewHolder) holder).setData(mList.get(position-1));
|
||||
((HeadViewHolder) holder).setData(mList.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +61,7 @@ public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkBean> {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public void setData(RandomPkBean bean) {
|
||||
public void setData(RandomPkUserBean bean) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -93,9 +88,13 @@ public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkBean> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(RandomPkBean bean) {
|
||||
public void setData(RandomPkUserBean bean) {
|
||||
super.setData(bean);
|
||||
int position = getAbsoluteAdapterPosition();
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
System.out.println("bean = " + bean);
|
||||
mNum.setText((position) + "");
|
||||
if (position % 2 == 0) {
|
||||
itemView.setBackgroundResource(R.drawable.bg_item_random_pk_type_1);
|
||||
@ -109,13 +108,14 @@ public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkBean> {
|
||||
mName.setText(bean.getUserNiceName());
|
||||
}
|
||||
mId.setText(bean.getId());
|
||||
mStatus.setText(bean.getStatus());
|
||||
if (bean.isPkIng()) {
|
||||
if (bean.isPk()) {
|
||||
mStatus.setText("PK中");
|
||||
ImgLoader.display(mContext, R.mipmap.ic_random_pk_pk, mPkStatus);
|
||||
} else {
|
||||
mStatus.setText("空闲");
|
||||
ImgLoader.display(mContext, R.mipmap.ic_random_pk_pk_unselect, mPkStatus);
|
||||
}
|
||||
if (bean.isFollow()) {
|
||||
if (bean.isAttention()) {
|
||||
ImgLoader.display(mContext, R.mipmap.ic_random_pk_like, mFollow);
|
||||
} else {
|
||||
ImgLoader.display(mContext, R.mipmap.ic_random_pk_like_unselect, mFollow);
|
||||
|
@ -1,33 +0,0 @@
|
||||
package com.yunbao.live.bean;
|
||||
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
|
||||
public class RandomPkBean extends UserBean {
|
||||
private String status;
|
||||
private boolean pkIng;
|
||||
private boolean follow;
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public boolean isPkIng() {
|
||||
return pkIng;
|
||||
}
|
||||
|
||||
public void setPkIng(boolean pkIng) {
|
||||
this.pkIng = pkIng;
|
||||
}
|
||||
|
||||
public boolean isFollow() {
|
||||
return follow;
|
||||
}
|
||||
|
||||
public void setFollow(boolean follow) {
|
||||
this.follow = follow;
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
package com.yunbao.live.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
@ -12,31 +15,39 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.RandomPkUserBean;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.utils.WordsTypeUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.RandomPkRecyclerAdapter;
|
||||
import com.yunbao.live.bean.RandomPkBean;
|
||||
import com.yunbao.live.bean.LivePkBean;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
import com.yunbao.live.utils.RandomPkManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 随机PK
|
||||
*/
|
||||
public class RandomPkDialogFragment extends AbsDialogFragment {
|
||||
public class RandomPkDialogFragment extends AbsDialogFragment implements View.OnClickListener {
|
||||
private static final String TAG = "随机PK";
|
||||
private int mLiveUid;
|
||||
private TabLayout tabLayout;
|
||||
private View reset;
|
||||
private CommonRefreshView mRecyclerView;
|
||||
@ -49,6 +60,21 @@ public class RandomPkDialogFragment extends AbsDialogFragment {
|
||||
private EditText mSearch;
|
||||
private ImageView mClear;
|
||||
private RandomPkRecyclerAdapter adapter;
|
||||
private DataHelper helper;
|
||||
|
||||
|
||||
private final RandomPkManager.OnRandomPkTimer randomPkTimer = new RandomPkManager.OnRandomPkTimer() {
|
||||
@Override
|
||||
public void onTimer(String time) {
|
||||
Log.i(TAG, "onTimer: "+time);
|
||||
mPkBtnTitle.setText(String.format(WordUtil.getString(R.string.random_pk_info_btn_ing), time));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartPK(String pkUid) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@ -75,6 +101,16 @@ public class RandomPkDialogFragment extends AbsDialogFragment {
|
||||
window.setAttributes(params);
|
||||
}
|
||||
|
||||
public void setLiveUid(int mLiveUid) {
|
||||
this.mLiveUid = mLiveUid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
RandomPkManager.getInstance().unregisterOnRandomPkTimer(randomPkTimer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
@ -95,23 +131,24 @@ public class RandomPkDialogFragment extends AbsDialogFragment {
|
||||
mRandomPkSwitch = (ImageView) findViewById(R.id.live_random_pk_switch);
|
||||
mSearch = (EditText) findViewById(R.id.search_edit);
|
||||
mClear = (ImageView) findViewById(R.id.search_clear);
|
||||
mClear.setOnClickListener(v -> {
|
||||
mSearch.setText("");
|
||||
});
|
||||
mClear.setOnClickListener(this);
|
||||
mRandomPkSwitch.setTag(true);
|
||||
mRandomPkSwitch.setOnClickListener(v -> {
|
||||
if (mRandomPkSwitch.getTag() != null && (boolean) mRandomPkSwitch.getTag()) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, mRandomPkSwitch);
|
||||
mRandomPkSwitch.setTag(false);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, mRandomPkSwitch);
|
||||
mRandomPkSwitch.setTag(true);
|
||||
}
|
||||
});
|
||||
mSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
mRandomPkSwitch.setOnClickListener(this);
|
||||
mPkBtn.setOnClickListener(this);
|
||||
mSearch.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
return false;
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
helper.search(s.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -119,65 +156,17 @@ public class RandomPkDialogFragment extends AbsDialogFragment {
|
||||
}
|
||||
|
||||
private void initRecycler() {
|
||||
helper = new DataHelper();
|
||||
adapter = new RandomPkRecyclerAdapter(mContext);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mRecyclerView.setDataHelper(new CommonRefreshView.DataHelper<RandomPkBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<RandomPkBean> getAdapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
callback.onSuccess(0, "", new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RandomPkBean> processData(String[] info) {
|
||||
Log.i(TAG, "processData: 获取数据成功");
|
||||
return createTmpData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<RandomPkBean> list, int listCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<RandomPkBean> loadItemList, int loadItemCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
mRecyclerView.setDataHelper(helper);
|
||||
mRecyclerView.initData();
|
||||
}
|
||||
|
||||
private List<RandomPkBean> createTmpData() {
|
||||
List<RandomPkBean> list = new ArrayList<>();
|
||||
for (int i = 1; i < 10; i++) {
|
||||
RandomPkBean bean = new RandomPkBean();
|
||||
bean.setId(i + "");
|
||||
bean.setAvatar("https://ceshi.yaoulive.com/default.jpg");
|
||||
bean.setUserNiceName(i + "测试样本123456");
|
||||
bean.setStatus(i % 3 == 0 ? "PK中" : "空闲");
|
||||
bean.setPkIng(i % 3 == 0);
|
||||
bean.setFollow(i % 2 == 0);
|
||||
list.add(bean);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
RandomPkManager.getInstance().addOnRandomPkTimer(randomPkTimer);
|
||||
initPkSwitch();
|
||||
}
|
||||
|
||||
private void initTab() {
|
||||
@ -202,6 +191,7 @@ public class RandomPkDialogFragment extends AbsDialogFragment {
|
||||
mSearchLayout.setVisibility(View.INVISIBLE);
|
||||
switch ((int) tab.getTag()) {
|
||||
case 1:
|
||||
mSearch.setText("");
|
||||
mSearchLayout.setVisibility(View.GONE);
|
||||
mPkInfoLayout.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
@ -229,4 +219,174 @@ public class RandomPkDialogFragment extends AbsDialogFragment {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置随机PK开关状态
|
||||
*
|
||||
* @param open on/off
|
||||
*/
|
||||
private void setSwitchBtn(boolean open) {
|
||||
if (open) {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_on, mRandomPkSwitch);
|
||||
mRandomPkSwitch.setTag(true);
|
||||
} else {
|
||||
ImgLoader.display(mContext, com.yunbao.common.R.mipmap.special_icon_off, mRandomPkSwitch);
|
||||
mRandomPkSwitch.setTag(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机PK状态
|
||||
*/
|
||||
private void initPkSwitch() {
|
||||
LiveNetManager.get(mContext)
|
||||
.getRandomPkSwitch(new com.yunbao.common.http.base.HttpCallback<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer data) {
|
||||
if (data != null) {
|
||||
setSwitchBtn(data == 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Dialog loadDialog;
|
||||
|
||||
/**
|
||||
* 设置随机PK状态
|
||||
*
|
||||
* @param pk 1=on,0=off
|
||||
*/
|
||||
private void setPkSwitch(int pk) {
|
||||
loadDialog = DialogUitl.loadingDialog(mContext);
|
||||
loadDialog.show();
|
||||
LiveNetManager.get(mContext)
|
||||
.changeRandomPkSwitch(pk, new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
loadDialog.dismiss();
|
||||
loadDialog = null;
|
||||
if (data.getCode() == 0) {
|
||||
setSwitchBtn(!(boolean) mRandomPkSwitch.getTag());
|
||||
} else {
|
||||
ToastUtil.show(data.getMsg());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
loadDialog.dismiss();
|
||||
loadDialog = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void randomPk() {
|
||||
if (mPkBtn.getTag() != null && (boolean) mPkBtn.getTag()) {
|
||||
RandomPkManager.getInstance().end();
|
||||
resetPkBtn();
|
||||
mPkBtn.setTag(false);
|
||||
return;
|
||||
}
|
||||
mPkBtnDesc.setVisibility(View.VISIBLE);
|
||||
mPkBtnDesc.setText(R.string.random_pk_info_btn_ing_desc);
|
||||
RandomPkManager.getInstance().start();
|
||||
mPkBtn.setTag(true);
|
||||
}
|
||||
|
||||
private void resetPkBtn() {
|
||||
mPkBtnDesc.setVisibility(View.GONE);
|
||||
mPkBtnTitle.setText(R.string.random_pk_info_btn_start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.live_random_pk_switch) {
|
||||
if (mRandomPkSwitch.getTag() != null && (boolean) mRandomPkSwitch.getTag()) {
|
||||
setPkSwitch(0);
|
||||
} else {
|
||||
setPkSwitch(1);
|
||||
}
|
||||
} else if (id == R.id.search_clear) {
|
||||
mSearch.setText("");
|
||||
} else if (id == R.id.random_pk_info_btn) {
|
||||
randomPk();
|
||||
}
|
||||
}
|
||||
|
||||
public class DataHelper implements CommonRefreshView.DataHelper<RandomPkUserBean> {
|
||||
|
||||
public void search(String key) {
|
||||
LiveNetManager.get(mContext)
|
||||
.randomPkSearchUser(key, WordsTypeUtil.changeTraditional(key), new com.yunbao.common.http.base.HttpCallback<List<RandomPkUserBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<RandomPkUserBean> data) {
|
||||
List<RandomPkUserBean> list = new ArrayList<>();
|
||||
list.add(null);
|
||||
list.addAll(data);
|
||||
adapter.setList(list);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefreshAdapter<RandomPkUserBean> getAdapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
LiveHttpUtil.getLivePkList(p, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RandomPkUserBean> processData(String[] info) {
|
||||
Log.i(TAG, "processData: 获取数据成功");
|
||||
List<LivePkBean> beans = JSON.parseArray(Arrays.toString(info), LivePkBean.class);
|
||||
List<RandomPkUserBean> list = new ArrayList<>();
|
||||
for (LivePkBean bean : beans) {
|
||||
RandomPkUserBean userBean = new RandomPkUserBean();
|
||||
userBean.setId(bean.getUid());
|
||||
userBean.setSex(bean.getSex());
|
||||
userBean.setUserNiceName(bean.getUserNiceName());
|
||||
userBean.setAvatar(bean.getAvatar());
|
||||
userBean.setPk(bean.getPkUid().equals("0") ? 0 : 1);
|
||||
userBean.setAttention("0");
|
||||
list.add(userBean);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<RandomPkUserBean> list, int listCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<RandomPkUserBean> loadItemList, int loadItemCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.manager.IMRTCManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||
@ -1204,7 +1205,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
agree = false;
|
||||
}
|
||||
boolean finalAgree = agree;
|
||||
rtcRoom.getLocalUser().responseJoinOtherRoom(mApplyUid, mApplyUid, agree, true, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() {
|
||||
IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, agree, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (finalAgree == true) {
|
||||
@ -1274,7 +1275,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
* 2:无论为true或false,双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局。一旦主动设置过合流布局,后续音视频直播过程中设置的自动合流参数将失效。
|
||||
* <P/>
|
||||
*/
|
||||
rtcRoom.getLocalUser().requestJoinOtherRoom(user.getString("id"), user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
|
||||
IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
@ -1308,7 +1309,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
|
||||
} else {
|
||||
if (mPkWaitCount < 0) {
|
||||
rtcRoom.getLocalUser().responseJoinOtherRoom(u.getId(), u.getId(), false, false, "extra", new IRCRTCResultCallback() {
|
||||
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
|
||||
|
||||
@Override
|
||||
public void onFailed(RTCErrorCode errorCode) {
|
||||
@ -1350,7 +1351,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
});
|
||||
|
||||
} else {
|
||||
rtcRoom.getLocalUser().responseJoinOtherRoom(u.getId(), u.getId(), false, false, "extra", new IRCRTCResultCallback() {
|
||||
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(),false, "extra", new IRCRTCResultCallback() {
|
||||
|
||||
@Override
|
||||
public void onFailed(RTCErrorCode errorCode) {
|
||||
|
@ -267,6 +267,7 @@ public class SocketRyClient {
|
||||
// case Constants.SOCKET_SEND_GIFT://送礼物
|
||||
// ////////pk
|
||||
// break;
|
||||
case Constants.SOCKET_LIVE_DRPK_RANDOM:
|
||||
case Constants.SOCKET_LIVE_DRPK://多人PK
|
||||
int action3 = map.getIntValue("action");
|
||||
//收到多人PK邀请
|
||||
|
103
live/src/main/java/com/yunbao/live/utils/RandomPkManager.java
Normal file
103
live/src/main/java/com/yunbao/live/utils/RandomPkManager.java
Normal file
@ -0,0 +1,103 @@
|
||||
package com.yunbao.live.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class RandomPkManager {
|
||||
private static RandomPkManager manager;
|
||||
private int min = -1;
|
||||
private int sec = -1;
|
||||
private Timer timer;
|
||||
private TimerTask task;
|
||||
private List<OnRandomPkTimer> randomPkTimer = new ArrayList<>();
|
||||
|
||||
private RandomPkManager() {
|
||||
initTask();
|
||||
}
|
||||
|
||||
public static RandomPkManager getInstance() {
|
||||
if (manager == null) {
|
||||
manager = new RandomPkManager();
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
public void addOnRandomPkTimer(OnRandomPkTimer randomPkTimer) {
|
||||
this.randomPkTimer.add(randomPkTimer);
|
||||
}
|
||||
|
||||
public void unregisterOnRandomPkTimer(OnRandomPkTimer randomPkTimer) {
|
||||
this.randomPkTimer.remove(randomPkTimer);
|
||||
}
|
||||
|
||||
private void initVal() {
|
||||
min = -1;
|
||||
sec = -1;
|
||||
}
|
||||
|
||||
private void initTask() {
|
||||
task = new TimerTask() {
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sec++;
|
||||
if (sec % 60 == 0) {
|
||||
min++;
|
||||
sec = 0;
|
||||
}
|
||||
handler.post(() -> {
|
||||
for (OnRandomPkTimer onRandomPkTimer : randomPkTimer) {
|
||||
onRandomPkTimer.onTimer(String.format(Locale.CHINA, "%02d:%02d", min, sec));
|
||||
}
|
||||
if (sec == 5) {
|
||||
LiveNetManager.get(CommonAppContext.getTopActivity())
|
||||
.randomPK(new HttpCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String data) {
|
||||
for (OnRandomPkTimer pkTimer : randomPkTimer) {
|
||||
pkTimer.onStartPK(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void start() {
|
||||
task.cancel();
|
||||
initTask();
|
||||
initVal();
|
||||
timer = new Timer();
|
||||
timer.schedule(task, 0, 1000);
|
||||
|
||||
}
|
||||
|
||||
public void end() {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
public interface OnRandomPkTimer {
|
||||
void onTimer(String time);
|
||||
|
||||
void onStartPK(String pkUid);
|
||||
}
|
||||
}
|
@ -35,6 +35,7 @@ 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.IMRTCManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
@ -476,7 +477,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
|
||||
// 保存房间对象
|
||||
rtcRoom = room;
|
||||
|
||||
IMRTCManager.getInstance().setRtcRoom(room);
|
||||
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
public void run() {
|
||||
@ -536,6 +537,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
return;
|
||||
}
|
||||
rtcRoom = room;
|
||||
IMRTCManager.getInstance().setRtcRoom(room);
|
||||
}
|
||||
rtcRoom.getLocalUser().publishDefaultLiveStreams(new IRCRTCResultDataCallback<RCRTCLiveInfo>() {
|
||||
@Override
|
||||
|
@ -68,8 +68,9 @@
|
||||
android:id="@+id/item_status"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="状态"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp" />
|
||||
@ -78,19 +79,17 @@
|
||||
android:id="@+id/item_pk"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="27dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center"
|
||||
android:src="@mipmap/ic_random_pk_pk"
|
||||
/>
|
||||
android:layout_weight="1"
|
||||
android:src="@mipmap/ic_random_pk_pk" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/item_follow"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="23dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center"
|
||||
android:src="@mipmap/ic_random_pk_like"
|
||||
/>
|
||||
android:layout_weight="1"
|
||||
android:src="@mipmap/ic_random_pk_like" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -39,8 +39,10 @@
|
||||
<string name="random_pk_info_desc_4" translatable="false">4、安全部門將會24小時巡查,請文明PK,嚴格遵守主播守則;</string>
|
||||
<string name="random_pk_info_switch" translatable="false">隨機PK開關:</string>
|
||||
<string name="random_pk_info_btn_start" translatable="false">開始匹配</string>
|
||||
<string name="random_pk_info_btn_ing" translatable="false">匹配中 %s \n再次點擊可取消匹配</string>
|
||||
<string name="random_pk_info_btn_end" translatable="false">正在退出匹配 %s \n退出過程中也有可能匹配到對手</string>
|
||||
<string name="random_pk_info_btn_ing" translatable="false">匹配中 %s </string>
|
||||
<string name="random_pk_info_btn_ing_desc" translatable="false">再次點擊可取消匹配</string>
|
||||
<string name="random_pk_info_btn_end" translatable="false">正在退出匹配 %s</string>
|
||||
<string name="random_pk_info_btn_end_desc" translatable="false">退出過程中也有可能匹配到對手</string>
|
||||
<string name="random_pk_search_hint" translatable="false">請輸入您要pk的主播昵稱或id</string>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user