修复聊天框名牌混乱问题
This commit is contained in:
parent
c9743f28a3
commit
dedb30d297
@ -77,6 +77,7 @@ import com.yunbao.live.socket.SocketClient;
|
||||
import com.yunbao.live.socket.SocketMessageListener;
|
||||
import com.yunbao.live.socket.SocketRyChatUtil;
|
||||
import com.yunbao.live.socket.SocketRyClient;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
import com.yunbao.live.utils.LoadDian9TuUtil;
|
||||
import com.yunbao.live.utils.UnzipFromAssets;
|
||||
import com.yunbao.live.views.AbsLiveViewHolder;
|
||||
@ -1522,6 +1523,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
|
||||
// mMobShareUtil = null;
|
||||
mImageUtil = null;
|
||||
SVGAViewUtils.clearSVGA();
|
||||
LiveTextRender.clear();
|
||||
L.e("LiveActivity--------release------>");
|
||||
|
||||
Constants.isSend = "0";
|
||||
|
@ -36,6 +36,9 @@ import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LiveChatBean;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/11.
|
||||
*/
|
||||
@ -49,7 +52,10 @@ public class LiveTextRender {
|
||||
private static AbsoluteSizeSpan sFontSizeSpan;
|
||||
private static AbsoluteSizeSpan sFontSizeSpan2;
|
||||
private static AbsoluteSizeSpan sFontSizeSpan3;
|
||||
private static Drawable mDrawableMedal, gzDrawables, ryxzDrawables, nhDrawables;
|
||||
private static final Map<LiveChatBean,Drawable> mDrawableMedalMap=new HashMap<>();
|
||||
private static final Map<LiveChatBean,Drawable> gzDrawablesMap=new HashMap<>();
|
||||
private static final Map<LiveChatBean,Drawable> ryxzDrawablesMap=new HashMap<>();
|
||||
private static final Map<LiveChatBean,Drawable> nhDrawablesMap=new HashMap<>();
|
||||
|
||||
static {
|
||||
sBoldSpan = new StyleSpan(Typeface.BOLD);
|
||||
@ -195,24 +201,24 @@ public class LiveTextRender {
|
||||
index += 2;
|
||||
}
|
||||
|
||||
if (gzDrawables != null) {//贵族
|
||||
if (gzDrawablesMap.containsKey(bean)) {//贵族
|
||||
builder.append(" ");
|
||||
gzDrawables.setBounds(0, 0, DpUtil.dp2px(32), DpUtil.dp2px(18));
|
||||
builder.setSpan(new VerticalImageSpan(gzDrawables), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
gzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(32), DpUtil.dp2px(18));
|
||||
builder.setSpan(new VerticalImageSpan(gzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
index += 2;
|
||||
}
|
||||
|
||||
if (ryxzDrawables != null) {//荣誉勋章
|
||||
if (ryxzDrawablesMap.containsKey(bean)) {//荣誉勋章
|
||||
builder.append(" ");
|
||||
ryxzDrawables.setBounds(0, 0, DpUtil.dp2px(18), DpUtil.dp2px(18));
|
||||
builder.setSpan(new VerticalImageSpan(ryxzDrawables), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ryxzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(18), DpUtil.dp2px(18));
|
||||
builder.setSpan(new VerticalImageSpan(ryxzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
index += 2;
|
||||
}
|
||||
|
||||
if (nhDrawables != null) {//靓号
|
||||
if (nhDrawablesMap.containsKey(bean)) {//靓号
|
||||
builder.append(" ");
|
||||
nhDrawables.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17));
|
||||
builder.setSpan(new VerticalImageSpan(nhDrawables), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
nhDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17));
|
||||
builder.setSpan(new VerticalImageSpan(nhDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
index += 2;
|
||||
}
|
||||
|
||||
@ -276,9 +282,8 @@ public class LiveTextRender {
|
||||
private static Drawable getMedalImage(final LiveChatBean bean) {
|
||||
View view = LayoutInflater.from(CommonAppContext.sInstance).inflate(R.layout.live_medal_icon, null, false);
|
||||
final ImageView iv = view.findViewById(R.id.ivIcon);
|
||||
|
||||
if (mDrawableMedal != null)
|
||||
iv.setImageDrawable(mDrawableMedal);
|
||||
if (mDrawableMedalMap.containsKey(bean))
|
||||
iv.setImageDrawable(mDrawableMedalMap.get(bean));
|
||||
TextView tv = view.findViewById(R.id.tvName);
|
||||
tv.setText(bean.getMedalNmae());
|
||||
//字体加粗
|
||||
@ -303,7 +308,7 @@ public class LiveTextRender {
|
||||
ImgLoader.displayDrawable(context, bean.getMedalLevelImageUrl(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
mDrawableMedal = drawable;
|
||||
mDrawableMedalMap.put(bean, drawable);
|
||||
gz(context, textView, bean);
|
||||
}
|
||||
|
||||
@ -319,14 +324,12 @@ public class LiveTextRender {
|
||||
ImgLoader.displayDrawable(context, bean.getMedal_honor(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
ryxzDrawables = null;
|
||||
ryxzDrawables = drawable;
|
||||
ryxzDrawablesMap.put(bean,drawable);
|
||||
nh(context, textView, bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
ryxzDrawables = null;
|
||||
nh(context, textView, bean);
|
||||
}
|
||||
});
|
||||
@ -334,10 +337,9 @@ public class LiveTextRender {
|
||||
|
||||
public static void nh(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
if (bean.getGood_nub() != null && !bean.getGood_nub().equals("")) {
|
||||
nhDrawables = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.good_nub);
|
||||
nhDrawablesMap.put(bean,ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.good_nub));
|
||||
renderTMP(context, textView, bean);
|
||||
} else {
|
||||
nhDrawables = null;
|
||||
renderTMP(context, textView, bean);
|
||||
}
|
||||
}
|
||||
@ -346,14 +348,12 @@ public class LiveTextRender {
|
||||
ImgLoader.displayDrawable(context, TextUtils.isEmpty(bean.getMedal_new()) ? bean.getMedal() : bean.getMedal_new(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
gzDrawables = null;
|
||||
gzDrawables = drawable;
|
||||
gzDrawablesMap.put(bean, drawable);
|
||||
ryxz(context, textView, bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
gzDrawables = null;
|
||||
ryxz(context, textView, bean);
|
||||
}
|
||||
});
|
||||
@ -490,7 +490,7 @@ public class LiveTextRender {
|
||||
ImgLoader.displayDrawable(context, bean.getMedalLevelImageUrl(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
mDrawableMedal = drawable;
|
||||
mDrawableMedalMap.put(bean, drawable);
|
||||
renderEnterRoomTMP(context, textView, bean);
|
||||
}
|
||||
|
||||
@ -604,6 +604,11 @@ public class LiveTextRender {
|
||||
builder.setSpan(sFontSizeSpan2, index1, index2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
mDrawableMedalMap.clear();
|
||||
gzDrawablesMap.clear();
|
||||
ryxzDrawablesMap.clear();
|
||||
nhDrawablesMap.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user