update 隨機/自由PK

This commit is contained in:
zlzw 2022-12-12 16:30:32 +08:00
parent ea69f4bcb7
commit 49167f332d
6 changed files with 54 additions and 26 deletions

View File

@ -50,6 +50,10 @@ public class RandomPkManager {
return manager; return manager;
} }
public int getStatus() {
return status;
}
/** /**
* 添加监听器 * 添加监听器
*/ */
@ -152,6 +156,13 @@ public class RandomPkManager {
return rankPkInfoBean != null && rankPkInfoBean.isRankPKTime(); return rankPkInfoBean != null && rankPkInfoBean.isRankPKTime();
} }
/**
* 是否为随机PK模式
*/
public boolean isRandomModel() {
return status == PK_STATUS_START || status == PK_STATUS_REQUEST || status == PK_STATUS_EXIT_ING;
}
/** /**
* 开始匹配 * 开始匹配
*/ */
@ -327,6 +338,9 @@ public class RandomPkManager {
* 设置PK状态 * 设置PK状态
*/ */
public void setPkStatus(int status) { public void setPkStatus(int status) {
if (!isRandomModel()) {
return;
}
if (this.status == PK_STATUS_DEFAULT || this.status == PK_STATUS_EXIT_ING) {//默认状态下不响应随机PK接口 if (this.status == PK_STATUS_DEFAULT || this.status == PK_STATUS_EXIT_ING) {//默认状态下不响应随机PK接口
return; return;
} }

View File

@ -134,7 +134,7 @@ public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
@Override @Override
public void onSuccess(SetAttentsModel data) { public void onSuccess(SetAttentsModel data) {
bean.setAttention(data.getIsattent()); bean.setAttention(data.getIsattent());
if ("1" .equals(data.getIsattent())) { if ("1".equals(data.getIsattent())) {
ToastUtil.show(R.string.following); ToastUtil.show(R.string.following);
mOnItemClickListener.onItemClick(bean, 1); mOnItemClickListener.onItemClick(bean, 1);
} else { } else {

View File

@ -1,6 +1,7 @@
package com.yunbao.live.presenter; package com.yunbao.live.presenter;
import android.app.Dialog; import android.app.Dialog;
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK; import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
@ -602,7 +603,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
} }
} else { } else {
isPK(); isPK(u);
} }
} }
@ -755,7 +756,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
private void isPK() { private void isPK(UserBean bean) {
ScreenDimenUtil util = ScreenDimenUtil.getInstance(); ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith(); int mScreenWdith = util.getScreenWdith();
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
@ -771,8 +772,12 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
msg1.put("pkuid", CommonAppConfig.getInstance().getUid()); msg1.put("pkuid", CommonAppConfig.getInstance().getUid());
msg1.put("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatarThumb()); msg1.put("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatarThumb());
msg1.put("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); msg1.put("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
if (bean != null && bean.isRandomPk()) {
IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, true, msg1.toString(), new IRCRTCResultCallback() { msg1.put("random_pk", bean.isRandomPk() ? 1 : 0);
msg1.put("is_ladders", bean.getRankPkImgUrl());
}
System.out.println("PK回执 = " + msg1.toString());
IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, true, msg1.toString(), new IRCRTCResultCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
RCRTCEngine.getInstance().joinOtherRoom(mApplyUid, new IRCRTCResultDataCallback<RCRTCOtherRoom>() { RCRTCEngine.getInstance().joinOtherRoom(mApplyUid, new IRCRTCResultDataCallback<RCRTCOtherRoom>() {
@ -968,7 +973,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE); mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
} }
if (mAcceptPk) { if (mAcceptPk) {
isPK(); isPK(u);
} else { } else {
if (mPkWaitCount < 0) { if (mPkWaitCount < 0) {
rtcRoom.getLocalUser().responseJoinOtherRoom(u.getId(), u.getId(), false, false, "extra", new IRCRTCResultCallback() { rtcRoom.getLocalUser().responseJoinOtherRoom(u.getId(), u.getId(), false, false, "extra", new IRCRTCResultCallback() {
@ -1012,8 +1017,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
}); });
} else {
refusePk(u);
} }
mApplyUid = null; mApplyUid = null;
mApplyStream = null; mApplyStream = null;
@ -1184,6 +1187,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
@Override @Override
public void onConfirmClick(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) { public void onConfirmClick(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) {
dialog.dismiss(); dialog.dismiss();
task.cancel();
apply(); apply();
} }
@ -1218,7 +1222,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
void apply() { void apply() {
isPK(); isPK(u);
} }
}) })
.build().show(); .build().show();
@ -1236,7 +1240,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
public void onSuccess() { public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean() final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LINK_MIC_PK) .param("_method_", SOCKET_LINK_MIC_PK)
// .param("randomPk",u.isRandomPk()+"") // .param("randomPk",u.isRandomPk()+"")
.param("action", 3); .param("action", 3);
msg1.create(); msg1.create();
@ -1988,7 +1992,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
if (mLiveLinkMicPkViewHolder != null) { if (mLiveLinkMicPkViewHolder != null) {
if (!TextUtils.isEmpty(winUid)) { if (!TextUtils.isEmpty(winUid)) {
if ("0" .equals(winUid)) { if ("0".equals(winUid)) {
mLiveLinkMicPkViewHolder.end(0); mLiveLinkMicPkViewHolder.end(0);
mLiveLinkMicPkViewHolder.hideTime(); mLiveLinkMicPkViewHolder.hideTime();
if (mHandler != null) { if (mHandler != null) {

View File

@ -1079,6 +1079,9 @@ public class SocketRyClient {
}); });
} }
mListener.onLinkMicPkClose(1); mListener.onLinkMicPkClose(1);
if (RandomPkManager.getInstance().isRandomModel()) {
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_DEFAULT);
}
break; break;
case 7://对方主播正在忙的回调 case 7://对方主播正在忙的回调
mListener.onLinkMicPkBusy(); mListener.onLinkMicPkBusy();

View File

@ -37,6 +37,7 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.IMRTCManager;
import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
@ -310,20 +311,25 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
userBean1.setUserNiceName("null"); userBean1.setUserNiceName("null");
userBean1.setAvatar("null"); userBean1.setAvatar("null");
} }
//单人PK减掉次数
if (!RandomPkManager.getInstance().isRandomModel()) {
ToastUtil.show("单人PK扣次数 = " + RandomPkManager.getInstance().getStatus());
LiveNetManager.get(mContext).setFreePkNum(new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
} else {
ToastUtil.show("随机PK不扣次数");
}
mLiveRyLinkMicPkPresenter.onLinkMicToPk(userBean1); mLiveRyLinkMicPkPresenter.onLinkMicToPk(userBean1);
mLiveRyLinkMicPkPresenter.onLinkMicPkStart(inviteeRoomId, 3); mLiveRyLinkMicPkPresenter.onLinkMicPkStart(inviteeRoomId, 3);
//单人PK减掉次数
LiveNetManager.get(mContext).setFreePkNum(new com.yunbao.common.http.base.HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
} }
} }
}); });
@ -379,6 +385,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override @Override
public void onConfirmClick(Dialog dialog, String content) { public void onConfirmClick(Dialog dialog, String content) {
//断开连麦 //断开连麦
HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout") HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout")
.execute(new HttpCallback() { .execute(new HttpCallback() {
@Override @Override

View File

@ -642,9 +642,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
//关注 //关注
FollowActivity.forward(mContext, CommonAppConfig.getInstance().getUid(), 0); FollowActivity.forward(mContext, CommonAppConfig.getInstance().getUid(), 0);
} else if (i == R.id.img_trophy) { } else if (i == R.id.img_trophy) {
// MainListActivity.forward(mContext, 0); MainListActivity.forward(mContext, 0);
RandomPkDialogFragment fragment = new RandomPkDialogFragment(); //RandomPkDialogFragment fragment = new RandomPkDialogFragment();
fragment.show(this.getSupportFragmentManager(), "RandomPkDialogFragment"); //fragment.show(this.getSupportFragmentManager(), "RandomPkDialogFragment");
} }