多人PK倒计时bug修改

This commit is contained in:
18401019693 2024-01-18 16:09:34 +08:00
parent ae6fdab7e8
commit 74b19de11c
2 changed files with 15 additions and 37 deletions

View File

@ -315,7 +315,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public static Handler mHandler; public static Handler mHandler;
private static final int WHAT_PK_TIME = 2;//pk时间变化 what private static final int WHAT_PK_TIME = 2;//pk时间变化 what
private static int mPkTimeCount;//pk时间 private static int mPkTimeCount, mPkTimeCount2;//pk时间
public static ImageView img_pk_fist_l, img_pk_fist_r; public static ImageView img_pk_fist_l, img_pk_fist_r;
public RoundedImageView avatar_l1, avatar_l2, avatar_l3, avatar_r1, avatar_r2, avatar_r3; public RoundedImageView avatar_l1, avatar_l2, avatar_l3, avatar_r1, avatar_r2, avatar_r3;
@ -5057,7 +5057,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} }
}; };
private Handler countdownHandler = new Handler();
private View detailsView = null; private View detailsView = null;
private FrameLayout timeTitle; private FrameLayout timeTitle;
private TextView textTime; private TextView textTime;
@ -5076,36 +5075,25 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
this.isShowGif = isShowGif; this.isShowGif = isShowGif;
} }
private boolean removeRunnable = false;
private boolean mShowLianBtn = false;
private Runnable countdownRunnable = new Runnable() { private Runnable countdownRunnable = new Runnable() {
@Override @Override
public void run() { public void run() {
if (removeRunnable) {
countdownHandler.removeCallbacks(countdownRunnable); if (mPkTimeCount2 > 0) {
timeTitle.setVisibility(View.VISIBLE); mPkTimeCount2--;
Log.e("多人Pk", "countdownRunnable mPkTimeCount:" + mPkTimeCount); if (mPkTimeCount2 == 0) {
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
Log.e("多人Pk", "countdownRunnable s1:" + s1);
countdownHandler.postDelayed(countdownRunnable, 1000);
removeRunnable = false;
} else {
mPkTimeCount--;
if (mPkTimeCount == 0) {
mShowLianBtn = false;
timeTitle.setVisibility(View.GONE); timeTitle.setVisibility(View.GONE);
countdownHandler.removeCallbacks(countdownRunnable); timeTitle.removeCallbacks(countdownRunnable);
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT)); .setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
} else { } else {
timeTitle.setVisibility(View.VISIBLE); timeTitle.setVisibility(View.VISIBLE);
Log.e("多人Pk", "countdownRunnable mPkTimeCount:" + mPkTimeCount); Log.e("多人Pk", "countdownRunnable mPkTimeCount:" + mPkTimeCount2);
String s1 = StringUtil.getDurationText(mPkTimeCount * 1000); String s1 = StringUtil.getDurationText(mPkTimeCount2 * 1000);
textTime.setText(String.format(mContext.getString(R.string.pk_time), s1)); textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
Log.e("多人Pk", "countdownRunnable s1:" + s1); Log.e("多人Pk", "countdownRunnable s1:" + s1);
countdownHandler.postDelayed(countdownRunnable, 1000); timeTitle.postDelayed(countdownRunnable, 1000);
} }
} }
} }
@ -5153,16 +5141,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}); });
if (time > 0) { if (time > 0) {
mPkTimeCount = time; mPkTimeCount2 = time;
if (mShowLianBtn) {
removeRunnable = true;
} else {
countdownHandler.postDelayed(countdownRunnable, 1000);
mShowLianBtn = true;
drPKtIME = time; drPKtIME = time;
} timeTitle.post(countdownRunnable);
} }
} }
Log.e("多人Pk", "upDataPkScore mPkTimeCount:" + mPkTimeCount); Log.e("多人Pk", "upDataPkScore mPkTimeCount:" + mPkTimeCount);
@ -5258,15 +5239,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
mRoot.removeView(detailsView); mRoot.removeView(detailsView);
detailsView = null; detailsView = null;
} }
mPkTimeCount = 0;
showAnchorSayAndCallAnchor(); showAnchorSayAndCallAnchor();
if (mHandler != null) { if (mHandler != null) {
mPkTimeCount = 0;
mHandler.removeMessages(WHAT_PK_TIME); mHandler.removeMessages(WHAT_PK_TIME);
} }
if (countdownHandler != null) {
removeRunnable = true;
mPkTimeCount = 0;
}
isShowGif = false; isShowGif = false;
if (voteManager != null) { if (voteManager != null) {
voteManager.hide(); voteManager.hide();

View File

@ -692,7 +692,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
} }
upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time")); upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time"));
Log.e("多人Pk", "enterRoomNew drpk_time:" + pkInfo.getIntValue("drpk_time"));
} }
// mLivePlayViewHolder.setLayoutInterface(new LivePlayRyViewHolder.PlayViewLayoutInterface() { // mLivePlayViewHolder.setLayoutInterface(new LivePlayRyViewHolder.PlayViewLayoutInterface() {
// @Override // @Override