From ddc246e11c5b35789d35d6bb5dcc140eca959f02 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 12 Dec 2022 18:18:36 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=A4=9A=E4=BA=BAPK=E4=B9=9F=E7=94=A8?= =?UTF-8?q?=E6=96=B0UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/manager/IMRTCManager.java | 5 ++--- .../com/yunbao/common/manager/RandomPkManager.java | 14 +++++++++++--- .../yunbao/live/activity/LiveRyAnchorActivity.java | 2 +- .../yunbao/live/dialog/RandomPkDialogFragment.java | 1 + 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java b/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java index a095e9b13..501daa08e 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java @@ -216,13 +216,12 @@ public class IMRTCManager { return; } if (waitTime-- == 0) { - new Handler(Looper.getMainLooper()).post(() -> ToastUtil.show("超时清除")); //callback.onFailed(JOIN_CHAT_ROOM_TIMEOUT); cancelRequestJoinOtherRoom(liveUid, "extra", new IRCRTCResultCallback() { @Override public void onSuccess() { requestUid.remove(liveUid); - if (RandomPkManager.getInstance().isRequestPk()) { + if (RandomPkManager.getInstance().isRandomModel()) { RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE); } } @@ -230,7 +229,7 @@ public class IMRTCManager { @Override public void onFailed(RTCErrorCode errorCode) { requestUid.remove(liveUid); - if (RandomPkManager.getInstance().isRequestPk()) { + if (RandomPkManager.getInstance().isRandomModel()) { RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE); } } diff --git a/common/src/main/java/com/yunbao/common/manager/RandomPkManager.java b/common/src/main/java/com/yunbao/common/manager/RandomPkManager.java index c7aa5aea1..f0890bb55 100644 --- a/common/src/main/java/com/yunbao/common/manager/RandomPkManager.java +++ b/common/src/main/java/com/yunbao/common/manager/RandomPkManager.java @@ -88,6 +88,7 @@ public class RandomPkManager { return; } task = new TimerTask() { + boolean isStartPk = false; @Override public void run() { @@ -100,7 +101,10 @@ public class RandomPkManager { for (OnRandomPkTimer onRandomPkTimer : randomPkTimer) { onRandomPkTimer.onTimer(String.format(Locale.CHINA, "%02d:%02d", min, sec)); } - nextPk(); + if (!isStartPk) { + nextPk(); + isStartPk = true; + } }); } }; @@ -120,6 +124,10 @@ public class RandomPkManager { if (status != PK_STATUS_DEFAULT && status != PK_STATUS_REFUSE) { return; } + new Handler(Looper.getMainLooper()).postDelayed(this::next, 5000); + } + + private void next() { status = PK_STATUS_REQUEST; LiveNetManager.get(CommonAppContext.getTopActivity()) .randomPK(new HttpCallback() { @@ -222,11 +230,11 @@ public class RandomPkManager { * 通知所有监听者,退出匹配成功 */ private void callEndPkSuccess() { + status = PK_STATUS_DEFAULT; + rankPkInfoBean = null; for (OnRandomPkTimer pkTimer : randomPkTimer) { pkTimer.onPkEndSuccess(); } - status = PK_STATUS_DEFAULT; - rankPkInfoBean = null; } private int exitTimer; diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 727e5abd8..7082aacc3 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -1136,7 +1136,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl } else { ToastUtil.show("主播正在PK,稍後再試"); - if (RandomPkManager.getInstance().isRequestPk()) { + if (RandomPkManager.getInstance().isRandomModel()) { RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE); } } diff --git a/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java index 244984618..a8552e9aa 100644 --- a/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java @@ -134,6 +134,7 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On mRandomPkSwitch.setTag(true); mRandomPkSwitch.setOnClickListener(this); mPkBtn.setOnClickListener(this); + mPkBtn.setTag(false); mPkBtn.setOnLongClickListener(v -> { DialogUitl.showSimpleInputDialog(mContext, "输入指定UID", new DialogUitl.SimpleCallback() { @Override