From 869ad9adf75a8c48528115d9ef812842fadcfd9b Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Mon, 12 Dec 2022 18:16:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=A4=9A=E4=BA=BAPk?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E5=8A=A8=E7=94=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/socket/SocketRyClient.java | 3 +- .../yunbao/live/views/LiveRoomViewHolder.java | 61 +++++++++++-------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index 9d3c9ef83..20565e983 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -295,7 +295,8 @@ public class SocketRyClient { } } else if (action3 == 5) { -// endDRGif(); + EventBus.getDefault().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT)); LiveRoomViewHolder.d_pk_view.setVisibility(View.GONE); if (LiveRyAnchorActivity.mLiveAnchorViewHolder != null) { dr_pk_view.setVisibility(View.GONE); 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 d79f48edf..d7bfdbaf3 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -331,6 +331,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis //全服通知 private ImageView customFullServiceNotify; + public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { super(context, parentView); Contexts = context; @@ -434,7 +435,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis /** * pk时间倒计时 */ - public static void changePkTime() { + public void changePkTime() { Log.i("tvt", mPkTimeCount + ""); mPkTimeCount--; if (mPkTimeCount > 0) {// @@ -449,34 +450,37 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); } -// endDRGif(); + endDRGif(); } } public void endDRGif() { - dr_pk_end_gif.setVisibility(View.VISIBLE); - RequestOptions options = new RequestOptions().skipMemoryCache(true);//配置 - Glide.with(Contexts).asGif() - .apply(options)//应用配置 - .load(R.mipmap.drpkend) - .listener(new RequestListener() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(GifDrawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if (resource instanceof GifDrawable) { - resource.setLoopCount(1);//只播放一次 + if (dr_pk_end_gif.getVisibility() == View.GONE) { + dr_pk_end_gif.setVisibility(View.VISIBLE); + RequestOptions options = new RequestOptions().skipMemoryCache(true);//配置 + Glide.with(Contexts).asGif() + .apply(options)//应用配置 + .load(R.mipmap.drpkend) + .listener(new RequestListener() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { + return false; } - //发送延时消息,通知动画结束 - mHandler.sendEmptyMessageDelayed(1, - 3000); - return false; - } - }) - .into(dr_pk_end_gif); + + @Override + public boolean onResourceReady(GifDrawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { + if (resource instanceof GifDrawable) { + resource.setLoopCount(1);//只播放一次 + } + //发送延时消息,通知动画结束 + mHandler.sendEmptyMessageDelayed(1, + 3000); + return false; + } + }) + .into(dr_pk_end_gif); + } + } @@ -491,7 +495,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis d_pk_view.setVisibility(View.VISIBLE); if (time != 0) { mPkTimeCount = time; - changePkTime(); + mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME, getNextSecondTime()); } @@ -644,7 +648,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis img.setImageResource(R.mipmap.icon_no4); } else if (j == 5) { img.setImageResource(R.mipmap.icon_no5); - }else { + } else { img.setImageResource(R.mipmap.icon_no1); } @@ -3805,6 +3809,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis case CUSTOM_FULL_SERVICE_NOTIFY: customFullServiceNotify(event.getCustomFullServiceNotifyEvent()); break; + case PK_TIME_COUNT: + endDRGif(); + break; } } @@ -3829,7 +3836,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } customFullServiceNotify.startAnimation(inAlphaAnimation); customFullServiceNotify.setVisibility(View.VISIBLE); - ImgLoader.display(mContext,customFullServiceNotifyEvent.getImg(),customFullServiceNotify); + ImgLoader.display(mContext, customFullServiceNotifyEvent.getImg(), customFullServiceNotify); customFullHandler.postDelayed(customFullRunnable, handlerDuration * 1000); } else {//文字通知