修改主播等级
This commit is contained in:
parent
a2fef0990a
commit
6841f47ac3
@ -70,7 +70,7 @@ public class ImgLoader {
|
||||
}
|
||||
RequestBuilder<Drawable> builder = Glide.with(context)
|
||||
.load(url)
|
||||
|
||||
|
||||
.thumbnail(thumbnail)
|
||||
.dontAnimate()
|
||||
.placeholder(imageView.getDrawable());
|
||||
@ -87,7 +87,21 @@ public class ImgLoader {
|
||||
Glide.with(context)
|
||||
.asDrawable()
|
||||
.load(url)
|
||||
|
||||
|
||||
.thumbnail(thumbnail)
|
||||
.placeholder(imageView.getDrawable())
|
||||
.dontAnimate()
|
||||
.skipMemoryCache(SKIP_MEMORY_CACHE)
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
public static void display2(Context context, Drawable drawable, ImageView imageView) {
|
||||
if (!contextIsExist(context)) {
|
||||
return;
|
||||
}
|
||||
Glide.with(context)
|
||||
.asDrawable()
|
||||
.load(drawable)
|
||||
.thumbnail(thumbnail)
|
||||
.placeholder(imageView.getDrawable())
|
||||
.dontAnimate()
|
||||
@ -142,7 +156,7 @@ public class ImgLoader {
|
||||
RequestBuilder<Drawable> builder = Glide.with(context)
|
||||
.load(url)
|
||||
.thumbnail(thumbnail)
|
||||
|
||||
|
||||
.error(R.mipmap.icon_avatar_placeholder);
|
||||
if (width != -1 && height != -1) {
|
||||
builder = builder.override(width, height);
|
||||
@ -165,7 +179,7 @@ public class ImgLoader {
|
||||
Glide.with(context)
|
||||
.asDrawable()
|
||||
.load(file)
|
||||
|
||||
|
||||
.thumbnail(thumbnail)
|
||||
.skipMemoryCache(SKIP_MEMORY_CACHE)
|
||||
.into(imageView);
|
||||
@ -178,7 +192,7 @@ public class ImgLoader {
|
||||
Glide.with(context)
|
||||
.asDrawable()
|
||||
.load(res)
|
||||
|
||||
|
||||
.thumbnail(thumbnail)
|
||||
.skipMemoryCache(SKIP_MEMORY_CACHE)
|
||||
.into(imageView);
|
||||
|
@ -77,7 +77,6 @@ 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,12 +1521,9 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
|
||||
mLiveContributeViewHolder = null;
|
||||
mLiveMedalRankViewHolder = null;
|
||||
mLiveLuckGiftTipViewHolder = null;
|
||||
// mMobShareUtil = null;
|
||||
mImageUtil = null;
|
||||
SVGAViewUtils.clearSVGA();
|
||||
LiveTextRender.clear();
|
||||
L.e("LiveActivity--------release------>");
|
||||
|
||||
Constants.isSend = "0";
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.pay.PayCallback;
|
||||
import com.yunbao.common.pay.PayPresenter;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.GiftCacheUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
@ -657,7 +658,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
super.onResume();
|
||||
manager.onResume();
|
||||
GiftCacheUtil.getInstance().restart();
|
||||
|
||||
Log.e(TAG, "Memory:" + DeviceUtils.getAvailMemory(mContext));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -874,7 +875,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
+ "&stream=" + mStream
|
||||
+ "&uid=" + CommonAppConfig.getInstance().getUid()
|
||||
+ "&token=" + CommonAppConfig.getInstance().getToken();
|
||||
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
|
||||
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
|
||||
bundle.putString("url", url);
|
||||
bundle.putInt("show_type", 0);
|
||||
liveHDDialogFragment.setArguments(bundle);
|
||||
|
@ -333,23 +333,23 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
} else if (bean.getType() == RECOMMEND_CARD_NOTIFY) {
|
||||
//加载.9图聊天气泡
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
LiveTextRender.recommendCardNotify(mContext, mTextView, bean);
|
||||
new LiveTextRender().recommendCardNotify(mContext, mTextView, bean);
|
||||
} else if (bean.getType() == AI_AUTOMATIC_SPEECH) {
|
||||
//加载.9图聊天气泡
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getAiAutomaticSpeechModel().getSystemBubble(), 1);
|
||||
LiveTextRender.aiAutomaticSpeech(mContext, mTextView, bean.getAiAutomaticSpeechModel());
|
||||
new LiveTextRender().aiAutomaticSpeech(mContext, mTextView, bean.getAiAutomaticSpeechModel());
|
||||
} else if (bean.getType() == STAR_CHALLENGE_UPGRADE_NOTIFY) {
|
||||
//加载.9图聊天气泡
|
||||
if (!TextUtils.isEmpty(bean.getMsgModel().getSystemBubble())) {
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystemBubble(), 1);
|
||||
LiveTextRender.starChallengeUpgradeNotify(mContext, mTextView, bean.getMsgModel());
|
||||
new LiveTextRender().starChallengeUpgradeNotify(mContext, mTextView, bean.getMsgModel());
|
||||
}
|
||||
} else if (bean.getType() == LUCKY_ANGEL) {
|
||||
if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) {
|
||||
bean.setId(bean.getMsgModel().getUserId());
|
||||
itemView.setTag(bean);
|
||||
LoadDian9TuUtil.loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1);
|
||||
LiveTextRender.luckyAngel(mContext, mTextView, bean.getMsgModel());
|
||||
new LiveTextRender().luckyAngel(mContext, mTextView, bean.getMsgModel());
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -365,7 +365,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
mTextView.setTextColor(0xffffffff);
|
||||
}
|
||||
|
||||
LiveTextRender.render(mContext, mTextView, bean);
|
||||
new LiveTextRender().render(mContext, mTextView, bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.bean.LiveUserGiftBean;
|
||||
import com.yunbao.live.dialog.LiveUserMoreDialogFragment;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
@ -279,7 +280,18 @@ public class UserMoreInfoAdapter extends RefreshAdapter<UserBean> {
|
||||
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
if (levelBean != null) {
|
||||
ImgLoader.display(mContext, levelBean.getThumb(), mLevel);
|
||||
new LiveTextRender().getLevelImage(mContext, levelBean.getLevel(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
ImgLoader.display2(mContext,drawable, mLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
if (bean.isHide() && (type.equals("5") || type.equals("4"))) {
|
||||
mName.setText(R.string.mystery_man);
|
||||
|
@ -460,10 +460,10 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
mLevelAnchorText.setText(String.valueOf(levelAnchor));
|
||||
mLevelText.setText(String.valueOf(level));
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(obj.getIntValue("sex")));
|
||||
mFollow.setText(LiveTextRender.renderLiveUserDialogData(obj.getLongValue("follows")));
|
||||
mFans.setText(LiveTextRender.renderLiveUserDialogData(obj.getLongValue("fans")));
|
||||
mConsume.setText(LiveTextRender.renderLiveUserDialogData(obj.getLongValue("consumption")));
|
||||
mVotes.setText(LiveTextRender.renderLiveUserDialogData(obj.getLongValue("votestotal")));
|
||||
mFollow.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("follows")));
|
||||
mFans.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("fans")));
|
||||
mConsume.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("consumption")));
|
||||
mVotes.setText(new LiveTextRender().renderLiveUserDialogData(obj.getLongValue("votestotal")));
|
||||
mConsumeTip.setText(WordUtil.getString(R.string.live_user_send) + appConfig.getCoinName());
|
||||
mVotesTip.setText(WordUtil.getString(R.string.live_user_get) + appConfig.getVotesName());
|
||||
if (mType == TYPE_AUD_ANC) {
|
||||
|
@ -431,7 +431,7 @@ public class LiveEnterRoomAnimPresenter {
|
||||
if (u.getVipType() != 0 || liveChatBean.getGuardType() != Constants.GUARD_TYPE_NONE) {
|
||||
needAnim = true;
|
||||
ImgLoader.displayAvatar(mContext, bean.getUserBean().getAvatar(), mAvatar);
|
||||
LiveTextRender.renderEnterRoom(mContext, mName, liveChatBean);
|
||||
new LiveTextRender().renderEnterRoom(mContext, mName, liveChatBean);
|
||||
mBgAnimator1.start();
|
||||
mUserAnimator1.start();
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package com.yunbao.live.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@ -20,8 +22,13 @@ import android.view.View.MeasureSpec;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
@ -45,19 +52,19 @@ import java.util.Map;
|
||||
|
||||
public class LiveTextRender {
|
||||
|
||||
private static StyleSpan sBoldSpan;
|
||||
private static StyleSpan sNormalSpan;
|
||||
private static ForegroundColorSpan sWhiteColorSpan;
|
||||
private static ForegroundColorSpan sGlobalColorSpan;
|
||||
private static AbsoluteSizeSpan sFontSizeSpan;
|
||||
private static AbsoluteSizeSpan sFontSizeSpan2;
|
||||
private static AbsoluteSizeSpan sFontSizeSpan3;
|
||||
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<>();
|
||||
private StyleSpan sBoldSpan;
|
||||
private StyleSpan sNormalSpan;
|
||||
private ForegroundColorSpan sWhiteColorSpan;
|
||||
private ForegroundColorSpan sGlobalColorSpan;
|
||||
private AbsoluteSizeSpan sFontSizeSpan;
|
||||
private AbsoluteSizeSpan sFontSizeSpan2;
|
||||
private AbsoluteSizeSpan sFontSizeSpan3;
|
||||
private final Map<LiveChatBean, Drawable> mDrawableMedalMap = new HashMap<>();
|
||||
private final Map<LiveChatBean, Drawable> gzDrawablesMap = new HashMap<>();
|
||||
private final Map<LiveChatBean, Drawable> ryxzDrawablesMap = new HashMap<>();
|
||||
private final Map<LiveChatBean, Drawable> nhDrawablesMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
public LiveTextRender() {
|
||||
sBoldSpan = new StyleSpan(Typeface.BOLD);
|
||||
sNormalSpan = new StyleSpan(Typeface.NORMAL);
|
||||
sWhiteColorSpan = new ForegroundColorSpan(0xffffffff);
|
||||
@ -73,7 +80,7 @@ public class LiveTextRender {
|
||||
* @param textView
|
||||
* @param bean
|
||||
*/
|
||||
public static void recommendCardNotify(Context context, TextView textView, LiveChatBean bean) {
|
||||
public void recommendCardNotify(Context context, TextView textView, LiveChatBean bean) {
|
||||
String recommend;
|
||||
Drawable drawable;
|
||||
if (TextUtils.equals(bean.getMsgModel().getRecommendCardType(), "1")) {
|
||||
@ -107,7 +114,7 @@ public class LiveTextRender {
|
||||
* @param textView
|
||||
* @param model
|
||||
*/
|
||||
public static void starChallengeUpgradeNotify(Context activity, TextView textView, MsgModel model) {
|
||||
public void starChallengeUpgradeNotify(Context activity, TextView textView, MsgModel model) {
|
||||
String star = activity.getString(R.string.star);
|
||||
String starString = String.format(activity.getString(R.string.star_success), model.getAncherName(), model.getCompetitionArea(), model.getStar());
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
|
||||
@ -126,7 +133,7 @@ public class LiveTextRender {
|
||||
/**
|
||||
* 幸运天使
|
||||
*/
|
||||
public static void luckyAngel(Context mContext, TextView mTextView, MsgModel msgModel) {
|
||||
public void luckyAngel(Context mContext, TextView mTextView, MsgModel msgModel) {
|
||||
String msg = mContext.getString(R.string.lucky_angel);
|
||||
msg = String.format(msg, msgModel.getUserName(), msgModel.getGiftName());
|
||||
int unameIndexOf = msg.indexOf(msgModel.getUserName());
|
||||
@ -140,7 +147,7 @@ public class LiveTextRender {
|
||||
mTextView.setText(builder);
|
||||
}
|
||||
|
||||
public static void aiAutomaticSpeech(Context activity, TextView textView, AiAutomaticSpeechModel model) {
|
||||
public void aiAutomaticSpeech(Context activity, TextView textView, AiAutomaticSpeechModel model) {
|
||||
ImgLoader.displayDrawable(activity, model.getIcon(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
@ -207,13 +214,13 @@ public class LiveTextRender {
|
||||
/**
|
||||
* 生成前缀
|
||||
*/
|
||||
private static SpannableStringBuilder createPrefix(Drawable levelDrawable, LiveChatBean bean) {
|
||||
private SpannableStringBuilder createPrefix(Drawable levelDrawable, LiveChatBean bean) {
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
int index = 0;
|
||||
|
||||
if (levelDrawable != null) {
|
||||
builder.append(" ");
|
||||
levelDrawable.setBounds(0, 0, DpUtil.dp2px(28), DpUtil.dp2px(14));
|
||||
levelDrawable.setBounds(0, 0, DpUtil.dp2px(32), DpUtil.dp2px(14));
|
||||
builder.setSpan(new VerticalImageSpan(levelDrawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
index += 2;
|
||||
}
|
||||
@ -264,7 +271,6 @@ public class LiveTextRender {
|
||||
if (drawable != null) {
|
||||
builder.append(" ");
|
||||
drawable.setBounds(0, 0, DpUtil.dp2px(42), DpUtil.dp2px(14));
|
||||
// drawable.setBounds(0, 0, DpUtil.dp2px(50), DpUtil.dp2px(20));//切图为138*38
|
||||
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
index += 2;
|
||||
}
|
||||
@ -296,22 +302,20 @@ public class LiveTextRender {
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static Drawable getMedalImage(final LiveChatBean bean) {
|
||||
private 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 (mDrawableMedalMap.containsKey(bean))
|
||||
iv.setImageDrawable(mDrawableMedalMap.get(bean));
|
||||
TextView tv = view.findViewById(R.id.tvName);
|
||||
tv.setText(bean.getMedalNmae());
|
||||
//字体加粗
|
||||
// tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,13);
|
||||
tv.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
Bitmap bitmap = convertViewToBitmap(view);
|
||||
Drawable drawable = new BitmapDrawable(bitmap);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
public static Bitmap convertViewToBitmap(View view) {
|
||||
public Bitmap convertViewToBitmap(View view) {
|
||||
view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
||||
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredWidth() / 3);
|
||||
// 153 72
|
||||
@ -321,7 +325,7 @@ public class LiveTextRender {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static void render(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
public void render(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
ImgLoader.displayDrawable(context, bean.getMedalLevelImageUrl(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
@ -337,7 +341,7 @@ public class LiveTextRender {
|
||||
}
|
||||
|
||||
|
||||
public static void ryxz(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
public void ryxz(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
ImgLoader.displayDrawable(context, bean.getMedal_honor(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
@ -352,7 +356,7 @@ public class LiveTextRender {
|
||||
});
|
||||
}
|
||||
|
||||
public static void nh(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
public void nh(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
if (bean.getGood_nub() != null && !bean.getGood_nub().equals("")) {
|
||||
nhDrawablesMap.put(bean, ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.good_nub));
|
||||
renderTMP(context, textView, bean);
|
||||
@ -361,7 +365,7 @@ public class LiveTextRender {
|
||||
}
|
||||
}
|
||||
|
||||
public static void gz(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
public void gz(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
ImgLoader.displayDrawable(context, TextUtils.isEmpty(bean.getMedal_new()) ? bean.getMedal() : bean.getMedal_new(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
@ -376,7 +380,61 @@ public class LiveTextRender {
|
||||
});
|
||||
}
|
||||
|
||||
private static void renderTMP(Context context, final TextView textView, final LiveChatBean bean) {
|
||||
/**
|
||||
* 等级设置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void getLevelImage(Context mContext, int userLevel, ImgLoader.DrawableCallback callback) {
|
||||
|
||||
String imgUrl = "https://downs.yaoulive.com/level/user_lv1_bg.png";
|
||||
if (0 < userLevel && userLevel < 10) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv1_bg.png";
|
||||
} else if (9 < userLevel && userLevel < 20) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv10_bg.png";
|
||||
} else if (19 < userLevel && userLevel < 30) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv20_bg.png";
|
||||
} else if (29 < userLevel && userLevel < 40) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv30_bg.png";
|
||||
} else if (39 < userLevel && userLevel < 50) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv40_bg.png";
|
||||
} else if (49 < userLevel && userLevel < 60) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv50_bg.png";
|
||||
} else if (59 < userLevel && userLevel < 70) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv60_bg.png";
|
||||
} else if (69 < userLevel && userLevel < 80) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv70_bg.png";
|
||||
} else if (79 < userLevel && userLevel < 90) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv80_bg.png";
|
||||
} else if (89 < userLevel && userLevel < 100) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv90_bg.png";
|
||||
} else if (99 < userLevel && userLevel < 110) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv100_bg.png";
|
||||
} else if (109 < userLevel && userLevel < 120) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv110_bg.png";
|
||||
} else if (userLevel == 120) {
|
||||
imgUrl = "https://downs.yaoulive.com/level/user_lv120_bg.png";
|
||||
}
|
||||
Glide.with(mContext).asBitmap().load(imgUrl).into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
;
|
||||
BitmapDrawable drawable = new BitmapDrawable(AddTimeWatermark(resource, String.valueOf(userLevel)));
|
||||
if (callback != null) {
|
||||
callback.onLoadSuccess(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
if (callback != null) {
|
||||
callback.onLoadFailed();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void renderTMP(Context context, final TextView textView, final LiveChatBean bean) {
|
||||
final LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
|
||||
|
||||
if (levelBean == null) {
|
||||
@ -395,10 +453,10 @@ public class LiveTextRender {
|
||||
textView.setText(builder);
|
||||
}
|
||||
} else {
|
||||
ImgLoader.displayDrawable(context, levelBean.getThumb(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
if (textView != null) {
|
||||
if (textView != null) {
|
||||
getLevelImage(context, bean.getLevel(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
SpannableStringBuilder builder = createPrefix(drawable, bean);
|
||||
int color = 0;
|
||||
if (bean.isAnchor()) {
|
||||
@ -420,17 +478,19 @@ public class LiveTextRender {
|
||||
}
|
||||
textView.setText(builder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
if (textView != null) {
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
SpannableStringBuilder builder = createPrefix(null, bean);
|
||||
int color = 0;
|
||||
if (bean.isAnchor()) {
|
||||
color = 0xffffdd00;
|
||||
} else {
|
||||
color = Color.parseColor(levelBean.getColor());
|
||||
try {
|
||||
color = Color.parseColor(levelBean.getColor());
|
||||
} catch (Exception e) {
|
||||
color = Color.parseColor("#ffffff");
|
||||
}
|
||||
}
|
||||
switch (bean.getType()) {
|
||||
case LiveChatBean.GIFT:
|
||||
@ -442,17 +502,43 @@ public class LiveTextRender {
|
||||
}
|
||||
textView.setText(builder);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bitmap添加文字
|
||||
*
|
||||
* @param mBitmap
|
||||
* @return
|
||||
*/
|
||||
private Bitmap AddTimeWatermark(Bitmap mBitmap, String level) {
|
||||
//获取原始图片与水印图片的宽与高
|
||||
int mBitmapWidth = mBitmap.getWidth();
|
||||
int mBitmapHeight = mBitmap.getHeight();
|
||||
Bitmap mNewBitmap = Bitmap.createBitmap(mBitmapWidth, mBitmapHeight, Bitmap.Config.ARGB_8888);
|
||||
Canvas mCanvas = new Canvas(mNewBitmap);
|
||||
//向位图中开始画入MBitmap原始图片
|
||||
mCanvas.drawBitmap(mBitmap, 0, 0, null);
|
||||
//添加文字
|
||||
Paint mPaint = new Paint();
|
||||
Typeface font = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
|
||||
mPaint.setColor(Color.WHITE);
|
||||
mPaint.setTextSize(50);
|
||||
mPaint.setTypeface(font);
|
||||
//水印的位置坐标
|
||||
mCanvas.drawText(level, 80, 53, mPaint);
|
||||
mCanvas.save();
|
||||
mCanvas.restore();
|
||||
return mNewBitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染普通聊天消息
|
||||
*/
|
||||
private static SpannableStringBuilder renderChat(int color, SpannableStringBuilder builder, LiveChatBean bean) {
|
||||
private SpannableStringBuilder renderChat(int color, SpannableStringBuilder builder, LiveChatBean bean) {
|
||||
int length = builder.length();
|
||||
String name = bean.getUserNiceName();
|
||||
if (bean.getType() != LiveChatBean.ENTER_ROOM) {//产品规定,进场消息不允许加冒号
|
||||
@ -487,7 +573,7 @@ public class LiveTextRender {
|
||||
/**
|
||||
* 渲染送礼物消息
|
||||
*/
|
||||
private static SpannableStringBuilder renderGift(int color, SpannableStringBuilder builder, LiveChatBean bean) {
|
||||
private SpannableStringBuilder renderGift(int color, SpannableStringBuilder builder, LiveChatBean bean) {
|
||||
int length = builder.length();
|
||||
String name = bean.getUserNiceName() + ":";
|
||||
builder.append(name);
|
||||
@ -503,7 +589,7 @@ public class LiveTextRender {
|
||||
/**
|
||||
* 渲染用户进入房间消息
|
||||
*/
|
||||
public static void renderEnterRoom(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
public void renderEnterRoom(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
ImgLoader.displayDrawable(context, bean.getMedalLevelImageUrl(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
@ -519,7 +605,7 @@ public class LiveTextRender {
|
||||
|
||||
}
|
||||
|
||||
private static void renderEnterRoomTMP(Context context, final TextView textView, final LiveChatBean bean) {
|
||||
private void renderEnterRoomTMP(Context context, final TextView textView, final LiveChatBean bean) {
|
||||
final LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
|
||||
if (levelBean == null) {
|
||||
return;
|
||||
@ -532,10 +618,6 @@ public class LiveTextRender {
|
||||
int start = builder.length();
|
||||
String name = bean.getUserNiceName() + " ";
|
||||
builder.append(name);
|
||||
//int end = start + name.length();
|
||||
//builder.setSpan(sWhiteColorSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
//builder.setSpan(sFontSizeSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
//builder.setSpan(sBoldSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.append(bean.getContent());
|
||||
textView.setText(builder);
|
||||
}
|
||||
@ -548,11 +630,6 @@ public class LiveTextRender {
|
||||
int start = builder.length();
|
||||
String name = bean.getUserNiceName() + " ";
|
||||
builder.append(name);
|
||||
// int end = start + name.length();
|
||||
// builder.setSpan(sWhiteColorSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
// builder.setSpan(sFontSizeSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
// builder.setSpan(sBoldSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
// builder.append(bean.getContent());
|
||||
textView.setText(builder);
|
||||
}
|
||||
}
|
||||
@ -561,7 +638,7 @@ public class LiveTextRender {
|
||||
}
|
||||
|
||||
|
||||
public static SpannableStringBuilder renderGiftInfo2(String giftName) {
|
||||
public SpannableStringBuilder renderGiftInfo2(String giftName) {
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
String s1 = WordUtil.getString(R.string.live_send_gift_1);
|
||||
String content = s1 + " " + giftName;
|
||||
@ -571,7 +648,7 @@ public class LiveTextRender {
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static SpannableStringBuilder renderGiftInfo(int giftCount, String giftName) {
|
||||
public SpannableStringBuilder renderGiftInfo(int giftCount, String giftName) {
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
String s1 = WordUtil.getString(R.string.live_send_gift_1);
|
||||
String s2 = WordUtil.getString(R.string.live_send_gift_2) + giftName;
|
||||
@ -585,7 +662,7 @@ public class LiveTextRender {
|
||||
}
|
||||
|
||||
|
||||
public static SpannableStringBuilder renderGiftCount(int count) {
|
||||
public SpannableStringBuilder renderGiftCount(int count) {
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
String s = String.valueOf(count);
|
||||
builder.append(s);
|
||||
@ -606,7 +683,7 @@ public class LiveTextRender {
|
||||
/**
|
||||
* 渲染直播间用户弹窗数据
|
||||
*/
|
||||
public static CharSequence renderLiveUserDialogData(long num) {
|
||||
public CharSequence renderLiveUserDialogData(long num) {
|
||||
if (num < 10000) {
|
||||
return String.valueOf(num);
|
||||
}
|
||||
@ -622,7 +699,7 @@ public class LiveTextRender {
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
public void clear() {
|
||||
mDrawableMedalMap.clear();
|
||||
gzDrawablesMap.clear();
|
||||
ryxzDrawablesMap.clear();
|
||||
|
@ -83,7 +83,7 @@ public class LiveGiftViewHolder extends AbsViewHolder {
|
||||
}
|
||||
if (mGiftCount != null && mGiftCount.getVisibility() != View.VISIBLE) {
|
||||
mGiftCount.setVisibility(View.VISIBLE);
|
||||
mGiftCount.setText(LiveTextRender.renderGiftCount(mLianCount));
|
||||
mGiftCount.setText(new LiveTextRender().renderGiftCount(mLianCount));
|
||||
}
|
||||
if (mGiftCount != null) {
|
||||
mGiftCount.clearAnimation();
|
||||
@ -152,7 +152,7 @@ public class LiveGiftViewHolder extends AbsViewHolder {
|
||||
}
|
||||
if (TextUtils.isEmpty(mLastGiftKey) || !mLastGiftKey.equals(bean.getKey())) {
|
||||
ImgLoader.display(mContext, bean.getGiftIcon(), mGiftIcon);
|
||||
mContent.setText(LiveTextRender.renderGiftInfo2(bean.getGiftName()));
|
||||
mContent.setText(new LiveTextRender().renderGiftInfo2(bean.getGiftName()));
|
||||
if (bean.getGiftCount() > 1) {
|
||||
mGiftGroupCount.setText("x" + bean.getGiftCount());
|
||||
mMulSign.setText(R.string.live_gift_send_lian_3);
|
||||
@ -174,7 +174,7 @@ public class LiveGiftViewHolder extends AbsViewHolder {
|
||||
mLianCount = bean.getLianCount();
|
||||
}
|
||||
if (mGiftCount != null && mGiftCount.getVisibility() == View.VISIBLE) {
|
||||
mGiftCount.setText(LiveTextRender.renderGiftCount(mLianCount));
|
||||
mGiftCount.setText(new LiveTextRender().renderGiftCount(mLianCount));
|
||||
}
|
||||
mLastGiftKey = bean.getKey();
|
||||
if (lian && mGiftCount != null && mAnimation != null) {
|
||||
|
@ -96,12 +96,9 @@ public class LuckLiveGiftViewHolder extends AbsViewHolder {
|
||||
if (mBg != null) {
|
||||
mBg.setTranslationX(-mDp214);
|
||||
}
|
||||
// if (mStar != null && mStar.getVisibility() == View.VISIBLE) {
|
||||
// mStar.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
if (mGiftCount != null && mGiftCount.getVisibility() != View.VISIBLE) {
|
||||
mGiftCount.setVisibility(View.VISIBLE);
|
||||
mGiftCount.setText(LiveTextRender.renderGiftCount(mLianCount));
|
||||
mGiftCount.setText(new LiveTextRender().renderGiftCount(mLianCount));
|
||||
}
|
||||
if (mGiftCount != null) {
|
||||
mGiftCount.clearAnimation();
|
||||
@ -204,7 +201,7 @@ public class LuckLiveGiftViewHolder extends AbsViewHolder {
|
||||
}
|
||||
if (TextUtils.isEmpty(mLastGiftKey) || !mLastGiftKey.equals(bean.getKey())) {
|
||||
ImgLoader.display(mContext, bean.getGiftIcon(), mGiftIcon);
|
||||
mContent.setText(LiveTextRender.renderGiftInfo2(bean.getGiftName()));
|
||||
mContent.setText(new LiveTextRender().renderGiftInfo2(bean.getGiftName()));
|
||||
if (bean.getGiftCount() > 1) {
|
||||
mGiftGroupCount.setText("x" + bean.getGiftCount());
|
||||
mMulSign.setText(R.string.live_gift_send_lian_3);
|
||||
@ -226,7 +223,7 @@ public class LuckLiveGiftViewHolder extends AbsViewHolder {
|
||||
mLianCount = bean.getLianCount();
|
||||
}
|
||||
if (mGiftCount != null && mGiftCount.getVisibility() == View.VISIBLE) {
|
||||
mGiftCount.setText(LiveTextRender.renderGiftCount(mLianCount));
|
||||
mGiftCount.setText(new LiveTextRender().renderGiftCount(mLianCount));
|
||||
}
|
||||
mLastGiftKey = bean.getKey();
|
||||
if (lian && mGiftCount != null && mAnimation != null) {
|
||||
|
@ -126,6 +126,7 @@
|
||||
android:id="@+id/level"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="15dp"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_marginLeft="5dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -2,22 +2,22 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivIcon"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvName"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="主播"
|
||||
android:layout_gravity="center"
|
||||
android:paddingLeft="13dp"
|
||||
android:text="主播"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="10sp"
|
||||
/>
|
||||
android:textSize="10sp" />
|
||||
|
||||
|
||||
</FrameLayout>
|
@ -92,10 +92,17 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right">
|
||||
|
||||
@ -107,7 +114,7 @@
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="10dp"
|
||||
android:visibility="gone" />
|
||||
android:visibility="visible" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
Loading…
Reference in New Issue
Block a user