修复下播后随即PK没有自动取消匹配
This commit is contained in:
parent
55f3ac577b
commit
87e3dddac5
@ -37,6 +37,8 @@ public class RandomPkManager {
|
||||
private String pkUid;//对方房间ID
|
||||
public static String debugUid;
|
||||
private RankPkInfoBean rankPkInfoBean;//排位赛信息
|
||||
private int exitTimer;//退出倒计时
|
||||
private TimerTask exitTask = null;//退出任务
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private RandomPkManager() {
|
||||
@ -118,6 +120,8 @@ public class RandomPkManager {
|
||||
return String.format(Locale.CHINA, "%02d:%02d", min, sec);
|
||||
}
|
||||
|
||||
private Runnable pkRunnable = this::next;
|
||||
|
||||
/**
|
||||
* 对方拒绝,开始下一轮匹配
|
||||
*/
|
||||
@ -125,11 +129,11 @@ public class RandomPkManager {
|
||||
if (status != PK_STATUS_DEFAULT && status != PK_STATUS_REFUSE) {
|
||||
return;
|
||||
}
|
||||
new Handler(Looper.getMainLooper()).postDelayed(this::next, 5000);
|
||||
handler.postDelayed(pkRunnable, 5000);
|
||||
}
|
||||
|
||||
private void next() {
|
||||
if (task==null) {
|
||||
if (task == null) {
|
||||
return;
|
||||
}
|
||||
status = PK_STATUS_REQUEST;
|
||||
@ -243,19 +247,9 @@ public class RandomPkManager {
|
||||
}
|
||||
}
|
||||
|
||||
private int exitTimer;
|
||||
|
||||
/**
|
||||
* 退出匹配
|
||||
*/
|
||||
public void exitPk() {
|
||||
if (status == PK_STATUS_EXIT_ING) {
|
||||
return;
|
||||
}
|
||||
callEndPkStart();
|
||||
status = PK_STATUS_EXIT_ING;
|
||||
exitTimer = 11;
|
||||
new Timer().schedule(new TimerTask() {
|
||||
private TimerTask createExitTask() {
|
||||
return new TimerTask() {
|
||||
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@ -269,10 +263,25 @@ public class RandomPkManager {
|
||||
end();
|
||||
callEndPkSuccess();
|
||||
cancel();
|
||||
exitTask = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 0, 1000);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出匹配
|
||||
*/
|
||||
public void exitPk() {
|
||||
if (status == PK_STATUS_EXIT_ING) {
|
||||
return;
|
||||
}
|
||||
callEndPkStart();
|
||||
status = PK_STATUS_EXIT_ING;
|
||||
exitTimer = 11;
|
||||
exitTask = createExitTask();
|
||||
new Timer().schedule(exitTask, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -387,6 +396,23 @@ public class RandomPkManager {
|
||||
return exitTimer + "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空状态,下播时调用
|
||||
*/
|
||||
public void release() {
|
||||
status = PK_STATUS_REQUEST;
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
}
|
||||
if (exitTask != null) {
|
||||
exitTask.cancel();
|
||||
}
|
||||
randomPkTimer.clear();
|
||||
rankPkInfoBean = null;
|
||||
pkUid = null;
|
||||
handler.removeCallbacks(pkRunnable);
|
||||
}
|
||||
|
||||
|
||||
public static abstract class OnRandomPkTimer {
|
||||
/**
|
||||
|
@ -843,6 +843,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
PKing = false;
|
||||
isDRPK = 0;
|
||||
endLive();
|
||||
RandomPkManager.getInstance().release();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user