update 随机PK&自由PK
This commit is contained in:
parent
285a33ff9a
commit
9eff246f06
@ -78,7 +78,7 @@ public class RandomPkManager {
|
|||||||
for (OnRandomPkTimer onRandomPkTimer : randomPkTimer) {
|
for (OnRandomPkTimer onRandomPkTimer : randomPkTimer) {
|
||||||
onRandomPkTimer.onTimer(String.format(Locale.CHINA, "%02d:%02d", min, sec));
|
onRandomPkTimer.onTimer(String.format(Locale.CHINA, "%02d:%02d", min, sec));
|
||||||
}
|
}
|
||||||
if (sec == 8) {
|
if (sec == 2) {
|
||||||
nextPk();
|
nextPk();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -143,6 +143,7 @@ public class RandomPkManager {
|
|||||||
for (OnRandomPkTimer pkTimer : randomPkTimer) {
|
for (OnRandomPkTimer pkTimer : randomPkTimer) {
|
||||||
pkTimer.onPkEndSuccess();
|
pkTimer.onPkEndSuccess();
|
||||||
}
|
}
|
||||||
|
status = PK_STATUS_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int exitTimer;
|
private int exitTimer;
|
||||||
@ -168,7 +169,6 @@ public class RandomPkManager {
|
|||||||
end();
|
end();
|
||||||
callEndPkSuccess();
|
callEndPkSuccess();
|
||||||
cancel();
|
cancel();
|
||||||
status = PK_STATUS_DEFAULT;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -234,6 +234,9 @@ public class RandomPkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPkStatus(int status) {
|
public void setPkStatus(int status) {
|
||||||
|
if(status==PK_STATUS_DEFAULT){//默认状态下不响应随机PK接口
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.status = status;
|
this.status = status;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case PK_STATUS_START:
|
case PK_STATUS_START:
|
||||||
|
@ -43,6 +43,8 @@ public class RandomPkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (getItemViewType(position) == ITEM) {
|
if (getItemViewType(position) == ITEM) {
|
||||||
|
((ItemViewHolder) holder).setData(mList.get(position-1));
|
||||||
|
}else{
|
||||||
((HeadViewHolder) holder).setData(mList.get(position));
|
((HeadViewHolder) holder).setData(mList.get(position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -588,8 +588,11 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
|||||||
mApplyNmae = u.getUserNiceName();
|
mApplyNmae = u.getUserNiceName();
|
||||||
if (by != 1) {
|
if (by != 1) {
|
||||||
if (mIsApplyDialogShow == false) {
|
if (mIsApplyDialogShow == false) {
|
||||||
// showApplyDialog(u);
|
if (u.isRandomPk()) {
|
||||||
showPkDialog(u);
|
showPkDialog(u);
|
||||||
|
} else {
|
||||||
|
showApplyDialog(u);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isPK();
|
isPK();
|
||||||
@ -1003,7 +1006,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
|||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
refusePk(u);
|
||||||
}
|
}
|
||||||
mApplyUid = null;
|
mApplyUid = null;
|
||||||
mApplyStream = null;
|
mApplyStream = null;
|
||||||
@ -1200,55 +1203,11 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
|||||||
|
|
||||||
cancelBtn.setVisibility(View.GONE);
|
cancelBtn.setVisibility(View.GONE);
|
||||||
confirmBtn.setOnClickListener(v -> {
|
confirmBtn.setOnClickListener(v -> {
|
||||||
refuse();
|
refusePk(u);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void refuse() {
|
|
||||||
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 (SocketRyClient.mSocketHandler != null) {
|
|
||||||
SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
|
|
||||||
Log.e("ry", "发送失敗" + u.getId());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
LiveNetManager.get(mContext).setBanRandomPK(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void apply() {
|
void apply() {
|
||||||
isPK();
|
isPK();
|
||||||
@ -1257,6 +1216,52 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
|||||||
.build().show();
|
.build().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void refusePk(UserBean u) {
|
||||||
|
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra_randm_pk", new IRCRTCResultCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailed(RTCErrorCode errorCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
final SocketSendBean msg1 = new SocketSendBean()
|
||||||
|
.param("_method_", SOCKET_LINK_MIC_PK)
|
||||||
|
// .param("randomPk",u.isRandomPk()+"")
|
||||||
|
.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 (SocketRyClient.mSocketHandler != null) {
|
||||||
|
SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
|
||||||
|
Log.e("ry", "发送失敗" + u.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
LiveNetManager.get(mContext).setBanRandomPK(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示申请多人PK的弹窗
|
* 显示申请多人PK的弹窗
|
||||||
*/
|
*/
|
||||||
|
@ -473,7 +473,7 @@ public class SocketRyClient {
|
|||||||
LiveChatBean chatBean = new LiveChatBean();
|
LiveChatBean chatBean = new LiveChatBean();
|
||||||
chatBean.setId(jsonObject.getString("uid"));
|
chatBean.setId(jsonObject.getString("uid"));
|
||||||
chatBean.setUserNiceName(jsonObject.getString("user_nicename"));
|
chatBean.setUserNiceName(jsonObject.getString("user_nicename"));
|
||||||
if ("1".equals(map.getString("msgtype"))) {
|
if ("1" .equals(map.getString("msgtype"))) {
|
||||||
chatBean.setType(-3);
|
chatBean.setType(-3);
|
||||||
} else {
|
} else {
|
||||||
chatBean.setType(-4);
|
chatBean.setType(-4);
|
||||||
@ -660,7 +660,7 @@ public class SocketRyClient {
|
|||||||
|
|
||||||
private static void sendActiveMsg(JSONObject map, SocketReceiveBean received) {
|
private static void sendActiveMsg(JSONObject map, SocketReceiveBean received) {
|
||||||
String msgtype = map.getString("msgtype");
|
String msgtype = map.getString("msgtype");
|
||||||
if ("1".equals(msgtype)) {//新年大作战活动
|
if ("1" .equals(msgtype)) {//新年大作战活动
|
||||||
LiveChatBean chatBean = new LiveChatBean();
|
LiveChatBean chatBean = new LiveChatBean();
|
||||||
chatBean.setId(map.getString("uid"));
|
chatBean.setId(map.getString("uid"));
|
||||||
chatBean.setMedalLevelImageUrl(map.getString("monster_str"));//昵称暂时做为活动图片地址
|
chatBean.setMedalLevelImageUrl(map.getString("monster_str"));//昵称暂时做为活动图片地址
|
||||||
@ -673,14 +673,14 @@ public class SocketRyClient {
|
|||||||
|
|
||||||
private static void wordLightEnterRoom(JSONObject map, SocketReceiveBean received) {
|
private static void wordLightEnterRoom(JSONObject map, SocketReceiveBean received) {
|
||||||
String msgtype = map.getString("msgtype");
|
String msgtype = map.getString("msgtype");
|
||||||
if ("2".equals(msgtype)) {//发言,点亮
|
if ("2" .equals(msgtype)) {//发言,点亮
|
||||||
if ("409002".equals(received.getRetcode())) {
|
if ("409002" .equals(received.getRetcode())) {
|
||||||
ToastUtil.show(R.string.live_you_are_shut);
|
ToastUtil.show(R.string.live_you_are_shut);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//禁言别人,自己发言只能自己看到
|
//禁言别人,自己发言只能自己看到
|
||||||
if ("409100".equals(received.getRetcode())) {
|
if ("409100" .equals(received.getRetcode())) {
|
||||||
String uid = map.getString("uid");
|
String uid = map.getString("uid");
|
||||||
if (!uid.equals(CommonAppConfig.getInstance().getUid())) {
|
if (!uid.equals(CommonAppConfig.getInstance().getUid())) {
|
||||||
return;
|
return;
|
||||||
@ -725,12 +725,12 @@ public class SocketRyClient {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!"".equals(map.getString("prankIcon")) && map.getString("prankIcon") != null) {
|
if (!"" .equals(map.getString("prankIcon")) && map.getString("prankIcon") != null) {
|
||||||
chatBean.setPrankIcon(map.getString("prankIcon"));
|
chatBean.setPrankIcon(map.getString("prankIcon"));
|
||||||
chatBean.setType(-5);
|
chatBean.setType(-5);
|
||||||
}
|
}
|
||||||
mListener.onChat(chatBean, 1);
|
mListener.onChat(chatBean, 1);
|
||||||
} else if ("0".equals(msgtype)) {//用户进入房间
|
} else if ("0" .equals(msgtype)) {//用户进入房间
|
||||||
JSONObject obj = JSON.parseObject(map.getString("ct"));
|
JSONObject obj = JSON.parseObject(map.getString("ct"));
|
||||||
LiveUserGiftBean u = GsonUtils.fromJson(obj.toJSONString(), LiveUserGiftBean.class);
|
LiveUserGiftBean u = GsonUtils.fromJson(obj.toJSONString(), LiveUserGiftBean.class);
|
||||||
UserBean.Vip vip = new UserBean.Vip();
|
UserBean.Vip vip = new UserBean.Vip();
|
||||||
@ -877,7 +877,7 @@ public class SocketRyClient {
|
|||||||
chatBean.setMedal_new(map.getString("medal_new"));
|
chatBean.setMedal_new(map.getString("medal_new"));
|
||||||
chatBean.setGood_nub(map.getString("good_num"));
|
chatBean.setGood_nub(map.getString("good_num"));
|
||||||
chatBean.setType(LiveChatBean.GIFT);
|
chatBean.setType(LiveChatBean.GIFT);
|
||||||
if (map.get("guard_type") != null && !"".equals(map.get("guard_type")) && !"null".equals(map.get("guard_type"))) {
|
if (map.get("guard_type") != null && !"" .equals(map.get("guard_type")) && !"null" .equals(map.get("guard_type"))) {
|
||||||
chatBean.setGuardType(map.getInteger("guard_type"));
|
chatBean.setGuardType(map.getInteger("guard_type"));
|
||||||
}
|
}
|
||||||
if (CommonAppContext.lang.equals("chinese")) {
|
if (CommonAppContext.lang.equals("chinese")) {
|
||||||
@ -1053,11 +1053,13 @@ public class SocketRyClient {
|
|||||||
mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid"));
|
mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid"));
|
||||||
break;
|
break;
|
||||||
case 3://对方主播拒绝PK的回调
|
case 3://对方主播拒绝PK的回调
|
||||||
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
|
if (map.containsKey("randomPk") && map.getString("randomPk").equals("true")) {
|
||||||
|
}
|
||||||
|
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
|
||||||
mListener.onLinkMicPkRefuse();
|
mListener.onLinkMicPkRefuse();
|
||||||
break;
|
break;
|
||||||
case 4://所有人收到PK开始址的回调
|
case 4://所有人收到PK开始址的回调
|
||||||
// RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
|
// RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
|
||||||
mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));
|
mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));
|
||||||
break;
|
break;
|
||||||
case 5://PK时候断开连麦的回调
|
case 5://PK时候断开连麦的回调
|
||||||
|
Loading…
Reference in New Issue
Block a user