From ae6fdab7e80e3a026d2306625aa8b5f5f9f03e27 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 18 Jan 2024 14:48:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E4=BA=BAPK=E5=80=92=E8=AE=A1=E6=97=B6?= =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/views/LiveRoomViewHolder.java | 85 +++++++++++-------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index f2e1eebcd..0004354b5 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -879,7 +879,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis d_pk_view.setVisibility(View.VISIBLE); if (time != 0) { mPkTimeCount = time; - mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME, getNextSecondTime()); + mHandler.sendEmptyMessageDelayed(WHAT_PK_TIME, getNextSecondTime()); } @@ -5057,18 +5057,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }; - private Handler countdownHandler = new Handler() { - @Override - public void handleMessage(@NonNull Message msg) { - switch (msg.what) { - case WHAT_PK_TIME: - countdownTime(); - break; - } - - super.handleMessage(msg); - } - }; + private Handler countdownHandler = new Handler(); private View detailsView = null; private FrameLayout timeTitle; private TextView textTime; @@ -5081,13 +5070,48 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * PK倒计时 */ private String userId2, userId3 = "", userId4; + private int drPKtIME; public void seisShowGif(boolean isShowGif) { this.isShowGif = isShowGif; } - public void upDataPkScore(JSONArray pkScores, int time) { + private boolean removeRunnable = false; + private boolean mShowLianBtn = false; + private Runnable countdownRunnable = new Runnable() { + @Override + public void run() { + if (removeRunnable) { + countdownHandler.removeCallbacks(countdownRunnable); + timeTitle.setVisibility(View.VISIBLE); + Log.e("多人Pk", "countdownRunnable mPkTimeCount:" + mPkTimeCount); + 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); + countdownHandler.removeCallbacks(countdownRunnable); + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT)); + } else { + timeTitle.setVisibility(View.VISIBLE); + Log.e("多人Pk", "countdownRunnable mPkTimeCount:" + mPkTimeCount); + 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); + } + } + } + }; + + public void upDataPkScore(JSONArray pkScores, int time) { isShowGif = true; if (detailsView == null) { detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null); @@ -5128,11 +5152,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }); - countdownHandler.removeMessages(WHAT_PK_TIME); if (time > 0) { mPkTimeCount = time; + if (mShowLianBtn) { + removeRunnable = true; + } else { + countdownHandler.postDelayed(countdownRunnable, 1000); + mShowLianBtn = true; + drPKtIME = time; + } + - countdownTime(); } } Log.e("多人Pk", "upDataPkScore mPkTimeCount:" + mPkTimeCount); @@ -5220,23 +5250,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis }); } -private synchronized void countdownTime(){ - mPkTimeCount--; - if (mPkTimeCount > 0) {// - timeTitle.setVisibility(View.VISIBLE); - Log.e("多人Pk", "countdownRunnable mPkTimeCount:" + mPkTimeCount); - String s1 = StringUtil.getDurationText(mPkTimeCount * 1000); - textTime.setText(String.format(mContext.getString(R.string.pk_time), s1)); - Log.e("多人Pk", "countdownRunnable s1:" + s1); - countdownHandler.sendEmptyMessageAtTime(WHAT_PK_TIME, getNextSecondTime()); - } else { - mPkTimeCount = 0; - timeTitle.setVisibility(View.GONE); - countdownHandler.removeCallbacksAndMessages(null); - Bus.get().post(new LiveAudienceEvent() - .setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT)); - } -} + public void removeDetailView() { @@ -5249,8 +5263,9 @@ private synchronized void countdownTime(){ if (mHandler != null) { mHandler.removeMessages(WHAT_PK_TIME); } - if (countdownHandler!=null){ - countdownHandler.removeMessages(WHAT_PK_TIME); + if (countdownHandler != null) { + removeRunnable = true; + mPkTimeCount = 0; } isShowGif = false; if (voteManager != null) {