修复一处内存泄漏

This commit is contained in:
zlzw 2022-12-05 15:10:36 +08:00
parent 6336eab32a
commit 0d422177ac
2 changed files with 23 additions and 16 deletions

View File

@ -195,10 +195,12 @@ public class LiveGiftAnimPresenter {
private WindowManager mWindowManager; private WindowManager mWindowManager;
private static FrameImageView mFrameImageView; private static FrameImageView mFrameImageView;
private static ValueAnimator mAnimator; private static ValueAnimator mAnimator;
private AllMsgTextRender textRender;
public LiveGiftAnimPresenter(Context context, View v, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { public LiveGiftAnimPresenter(Context context, View v, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) {
mContext = context; mContext = context;
this.mWindowManager = windowManager; this.mWindowManager = windowManager;
textRender = new AllMsgTextRender(this);
mParent2 = (ViewGroup) v.findViewById(R.id.gift_group_1); mParent2 = (ViewGroup) v.findViewById(R.id.gift_group_1);
mTopLuckContainer = v.findViewById(R.id.luck_container); mTopLuckContainer = v.findViewById(R.id.luck_container);
mGifImageView = gifImageView; mGifImageView = gifImageView;
@ -376,7 +378,7 @@ public class LiveGiftAnimPresenter {
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override @Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { 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 @Override
@ -835,7 +837,7 @@ public class LiveGiftAnimPresenter {
mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE); mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimatorAllServer.start(); 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); mGifGiftTipGroupBuyGuard.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimatorBuyGuard.start(); 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); mGifGiftTipGroupBuyVip.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimatorBuyVip.start(); 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); mGifGiftTipGroupAllServer.setVisibility(View.VISIBLE);
mGifGiftTipShowAnimatorAllServer.start(); 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; public static CountDownTimer countDownTimer, countDownTimerStart;
//intoIndex 横幅类型 //intoIndex 横幅类型
public static void setCountDownTimerEnd(int intoIndex) { public void setCountDownTimerEnd(int intoIndex) {
countDownTimer = new CountDownTimer(500, 250) { countDownTimer = new CountDownTimer(500, 250) {
@Override @Override
public void onTick(long millisUntilFinished) { public void onTick(long millisUntilFinished) {
@ -1686,7 +1688,7 @@ public class LiveGiftAnimPresenter {
countDownTimer.start(); countDownTimer.start();
} }
public static void setCountDownTimerStart(int intoIndex) { public void setCountDownTimerStart(int intoIndex) {
countDownTimerStart = new CountDownTimer(2000, 1000) { countDownTimerStart = new CountDownTimer(2000, 1000) {
@Override @Override
public void onTick(long millisUntilFinished) { public void onTick(long millisUntilFinished) {
@ -1720,7 +1722,7 @@ public class LiveGiftAnimPresenter {
countDownTimerStart.start(); countDownTimerStart.start();
} }
public static void setCountDownTimerStartAll() { public void setCountDownTimerStartAll() {
mFrameImageView.setVisibility(View.VISIBLE); mFrameImageView.setVisibility(View.VISIBLE);
mAnimator.start(); mAnimator.start();
mFrameImageView.setImageList(LiveIconUtil.getSAllMSG());//PK开始动画 mFrameImageView.setImageList(LiveIconUtil.getSAllMSG());//PK开始动画

View File

@ -16,12 +16,17 @@ import com.yunbao.live.presenter.LiveGiftAnimPresenter;
public class AllMsgTextRender { 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) { if (intoIndex == 4) {
textView.setText(name); textView.setText(name);
LiveGiftAnimPresenter.setCountDownTimerEnd(1); giftAnimPresenter.setCountDownTimerEnd(1);
return; return;
} }
builder = new SpannableStringBuilder(); builder = new SpannableStringBuilder();
@ -66,7 +71,7 @@ public class AllMsgTextRender {
builder = createPrefix(drawable, builder); builder = createPrefix(drawable, builder);
builder = renderMsg(color2, builder, text); builder = renderMsg(color2, builder, text);
textView.setText(builder); textView.setText(builder);
LiveGiftAnimPresenter.setCountDownTimerEnd(intoIndex); giftAnimPresenter.setCountDownTimerEnd(intoIndex);
} }
@Override @Override
@ -74,7 +79,7 @@ public class AllMsgTextRender {
builder = createPrefix(null, builder); builder = createPrefix(null, builder);
builder = renderMsg(color2, builder, text); builder = renderMsg(color2, builder, text);
textView.setText(builder); textView.setText(builder);
LiveGiftAnimPresenter.setCountDownTimerEnd(intoIndex); giftAnimPresenter.setCountDownTimerEnd(intoIndex);
} }
}); });
} else { } else {
@ -112,14 +117,14 @@ public class AllMsgTextRender {
builder = renderMsg(color2, builder, text2); builder = renderMsg(color2, builder, text2);
textView.setText(builder); textView.setText(builder);
// textView.init(windowManager); // 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(); int length = builder.length();
builder.append(str); builder.append(str);
builder.setSpan(new ForegroundColorSpan(color), length, length + str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 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(); int index = builder.length();
if (levelDrawable != null) { if (levelDrawable != null) {