diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java index ceb97efb0..9033417f5 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java @@ -195,10 +195,12 @@ public class LiveGiftAnimPresenter { private WindowManager mWindowManager; private static FrameImageView mFrameImageView; private static ValueAnimator mAnimator; + private AllMsgTextRender textRender; public LiveGiftAnimPresenter(Context context, View v, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { mContext = context; this.mWindowManager = windowManager; + textRender = new AllMsgTextRender(this); mParent2 = (ViewGroup) v.findViewById(R.id.gift_group_1); mTopLuckContainer = v.findViewById(R.id.luck_container); mGifImageView = gifImageView; @@ -376,7 +378,7 @@ public class LiveGiftAnimPresenter { new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { @Override public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { - RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal)); + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal)); } @Override @@ -835,7 +837,7 @@ public class LiveGiftAnimPresenter { mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE); mGifGiftTipShowAnimatorAllServer.start(); - AllMsgTextRender.render(mContext, mGifGiftTipAllServer, mTempGifGiftBean.getGiftIcon(), mTempGifGiftBean.getUserNiceName(), mAncherName, mTempGifGiftBean.getGiftName(), 1, mWindowManager, ""); + textRender.render(mContext, mGifGiftTipAllServer, mTempGifGiftBean.getGiftIcon(), mTempGifGiftBean.getUserNiceName(), mAncherName, mTempGifGiftBean.getGiftName(), 1, mWindowManager, ""); } } @@ -891,7 +893,7 @@ public class LiveGiftAnimPresenter { mGifGiftTipGroupBuyGuard.setVisibility(View.VISIBLE); mGifGiftTipShowAnimatorBuyGuard.start(); - AllMsgTextRender.render(mContext, mGifGiftTipBuyGuard, "", mTempGifGiftBean.getUserNiceName(), mAncherName, "", 2, mWindowManager, mTempGifGiftBean.getGuardType()); + textRender.render(mContext, mGifGiftTipBuyGuard, "", mTempGifGiftBean.getUserNiceName(), mAncherName, "", 2, mWindowManager, mTempGifGiftBean.getGuardType()); } } } @@ -1020,7 +1022,7 @@ public class LiveGiftAnimPresenter { mGifGiftTipGroupBuyVip.setVisibility(View.VISIBLE); mGifGiftTipShowAnimatorBuyVip.start(); - AllMsgTextRender.render(mContext, mGifGiftTipBuyVip, "", mTempGifGiftBean.getUserNiceName(), mAncherName, bean.getNobilityname(), 3, mWindowManager, bean.getOpentype()); + textRender.render(mContext, mGifGiftTipBuyVip, "", mTempGifGiftBean.getUserNiceName(), mAncherName, bean.getNobilityname(), 3, mWindowManager, bean.getOpentype()); } } } @@ -1051,7 +1053,7 @@ public class LiveGiftAnimPresenter { mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE); mGifGiftTipShowAnimatorAllServer.start(); - AllMsgTextRender.render(mContext, mGifGiftTipAllServer, "", bean.getVipName(), "", "", 4, mWindowManager, ""); + textRender.render(mContext, mGifGiftTipAllServer, "", bean.getVipName(), "", "", 4, mWindowManager, ""); } } @@ -1628,7 +1630,7 @@ public class LiveGiftAnimPresenter { public static CountDownTimer countDownTimer, countDownTimerStart; //intoIndex 横幅类型 - public static void setCountDownTimerEnd(int intoIndex) { + public void setCountDownTimerEnd(int intoIndex) { countDownTimer = new CountDownTimer(500, 250) { @Override public void onTick(long millisUntilFinished) { @@ -1686,7 +1688,7 @@ public class LiveGiftAnimPresenter { countDownTimer.start(); } - public static void setCountDownTimerStart(int intoIndex) { + public void setCountDownTimerStart(int intoIndex) { countDownTimerStart = new CountDownTimer(2000, 1000) { @Override public void onTick(long millisUntilFinished) { @@ -1720,7 +1722,7 @@ public class LiveGiftAnimPresenter { countDownTimerStart.start(); } - public static void setCountDownTimerStartAll() { + public void setCountDownTimerStartAll() { mFrameImageView.setVisibility(View.VISIBLE); mAnimator.start(); mFrameImageView.setImageList(LiveIconUtil.getSAllMSG());//PK开始动画 diff --git a/live/src/main/java/com/yunbao/live/utils/AllMsgTextRender.java b/live/src/main/java/com/yunbao/live/utils/AllMsgTextRender.java index 5bcc50e4c..53e515f8b 100644 --- a/live/src/main/java/com/yunbao/live/utils/AllMsgTextRender.java +++ b/live/src/main/java/com/yunbao/live/utils/AllMsgTextRender.java @@ -16,12 +16,17 @@ import com.yunbao.live.presenter.LiveGiftAnimPresenter; public class AllMsgTextRender { - public static SpannableStringBuilder builder; + public SpannableStringBuilder builder; + private LiveGiftAnimPresenter giftAnimPresenter; - public static void render(final Context context, final TextView textView, final String url, String name, String nameAncher, final String text, int intoIndex, WindowManager windowManager, String type) { + public AllMsgTextRender(LiveGiftAnimPresenter giftAnimPresenter) { + this.giftAnimPresenter = giftAnimPresenter; + } + + public void render(final Context context, final TextView textView, final String url, String name, String nameAncher, final String text, int intoIndex, WindowManager windowManager, String type) { if (intoIndex == 4) { textView.setText(name); - LiveGiftAnimPresenter.setCountDownTimerEnd(1); + giftAnimPresenter.setCountDownTimerEnd(1); return; } builder = new SpannableStringBuilder(); @@ -66,7 +71,7 @@ public class AllMsgTextRender { builder = createPrefix(drawable, builder); builder = renderMsg(color2, builder, text); textView.setText(builder); - LiveGiftAnimPresenter.setCountDownTimerEnd(intoIndex); + giftAnimPresenter.setCountDownTimerEnd(intoIndex); } @Override @@ -74,7 +79,7 @@ public class AllMsgTextRender { builder = createPrefix(null, builder); builder = renderMsg(color2, builder, text); textView.setText(builder); - LiveGiftAnimPresenter.setCountDownTimerEnd(intoIndex); + giftAnimPresenter.setCountDownTimerEnd(intoIndex); } }); } else { @@ -112,14 +117,14 @@ public class AllMsgTextRender { builder = renderMsg(color2, builder, text2); textView.setText(builder); // textView.init(windowManager); - LiveGiftAnimPresenter.setCountDownTimerEnd(intoIndex); + giftAnimPresenter.setCountDownTimerEnd(intoIndex); } } /** * 渲染消息 */ - private static SpannableStringBuilder renderMsg(int color, SpannableStringBuilder builder, String str) { + private SpannableStringBuilder renderMsg(int color, SpannableStringBuilder builder, String str) { int length = builder.length(); builder.append(str); builder.setSpan(new ForegroundColorSpan(color), length, length + str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -130,7 +135,7 @@ public class AllMsgTextRender { /** * 图片 */ - private static SpannableStringBuilder createPrefix(Drawable levelDrawable, SpannableStringBuilder builder) { + private SpannableStringBuilder createPrefix(Drawable levelDrawable, SpannableStringBuilder builder) { int index = builder.length(); if (levelDrawable != null) {