|
|
|
|
@@ -37,6 +37,7 @@ import com.yunbao.common.bean.LevelBean;
|
|
|
|
|
import com.yunbao.common.bean.MsgModel;
|
|
|
|
|
import com.yunbao.common.custom.VerticalImageSpan;
|
|
|
|
|
import com.yunbao.common.glide.ImgLoader;
|
|
|
|
|
import com.yunbao.common.utils.BitmapUtil;
|
|
|
|
|
import com.yunbao.common.utils.DpUtil;
|
|
|
|
|
import com.yunbao.common.utils.StringUtil;
|
|
|
|
|
import com.yunbao.common.utils.WordUtil;
|
|
|
|
|
@@ -46,6 +47,14 @@ import com.yunbao.live.bean.LiveChatBean;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import io.reactivex.Observable;
|
|
|
|
|
import io.reactivex.ObservableEmitter;
|
|
|
|
|
import io.reactivex.ObservableOnSubscribe;
|
|
|
|
|
import io.reactivex.Observer;
|
|
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
|
|
import io.reactivex.disposables.Disposable;
|
|
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by cxf on 2018/10/11.
|
|
|
|
|
*/
|
|
|
|
|
@@ -270,7 +279,7 @@ public class LiveTextRender {
|
|
|
|
|
Drawable drawable = getMedalImage(bean);
|
|
|
|
|
if (drawable != null) {
|
|
|
|
|
builder.append(" ");
|
|
|
|
|
drawable.setBounds(0, 0, DpUtil.dp2px(42), DpUtil.dp2px(14));
|
|
|
|
|
drawable.setBounds(0, 0, DpUtil.dp2px(44), DpUtil.dp2px(17));
|
|
|
|
|
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
index += 2;
|
|
|
|
|
}
|
|
|
|
|
@@ -380,36 +389,38 @@ public class LiveTextRender {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ImgLoader.DrawableCallback mCallback;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 等级设置
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public void getLevelImage(Context mContext, int userLevel, boolean anchorUserType, ImgLoader.DrawableCallback callback) {
|
|
|
|
|
|
|
|
|
|
String imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv1_bg.png" : "https://downs.yaoulive.com/level/user_lv1_bg.png";
|
|
|
|
|
public void getLevelImage(Context mContext, int userLevel, ImgLoader.DrawableCallback callback) {
|
|
|
|
|
mCallback = callback;
|
|
|
|
|
String imgUrl = "https://downs.yaoulive.com/level/user_lv1_bg.png";
|
|
|
|
|
if (0 < userLevel && userLevel < 10) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv1_bg.png" : "https://downs.yaoulive.com/level/user_lv1_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv1_bg.png";
|
|
|
|
|
} else if (9 < userLevel && userLevel < 20) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv10_bg.png" : "https://downs.yaoulive.com/level/user_lv10_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv10_bg.png";
|
|
|
|
|
} else if (19 < userLevel && userLevel < 30) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_l20_bg.png" : "https://downs.yaoulive.com/level/user_lv20_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv20_bg.png";
|
|
|
|
|
} else if (29 < userLevel && userLevel < 40) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv30_bg.png" : "https://downs.yaoulive.com/level/user_lv30_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv30_bg.png";
|
|
|
|
|
} else if (39 < userLevel && userLevel < 50) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv40_bg.png" : "https://downs.yaoulive.com/level/user_lv40_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv40_bg.png";
|
|
|
|
|
} else if (49 < userLevel && userLevel < 60) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv50_bg.png" : "https://downs.yaoulive.com/level/user_lv50_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv50_bg.png";
|
|
|
|
|
} else if (59 < userLevel && userLevel < 70) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv60_bg.png" : "https://downs.yaoulive.com/level/user_lv60_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv60_bg.png";
|
|
|
|
|
} else if (69 < userLevel && userLevel < 80) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv70_bg.png" : "https://downs.yaoulive.com/level/user_lv70_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv70_bg.png";
|
|
|
|
|
} else if (79 < userLevel && userLevel < 90) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv80_bg.png" : "https://downs.yaoulive.com/level/user_lv80_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv80_bg.png";
|
|
|
|
|
} else if (89 < userLevel && userLevel < 100) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv90_bg.png" : "https://downs.yaoulive.com/level/user_lv90_bg.png";
|
|
|
|
|
imgUrl = "https://downs.yaoulive.com/level/user_lv90_bg.png";
|
|
|
|
|
} else if (99 < userLevel && userLevel < 110) {
|
|
|
|
|
imgUrl = anchorUserType ? "https://downs.yaoulive.com/level/anchor_lv100_bg.png" : "https://downs.yaoulive.com/level/user_lv100_bg.png";
|
|
|
|
|
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) {
|
|
|
|
|
@@ -418,13 +429,40 @@ public class LiveTextRender {
|
|
|
|
|
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)));
|
|
|
|
|
Observable.create(new ObservableOnSubscribe<Bitmap>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void subscribe(ObservableEmitter<Bitmap> emitter) throws Exception {
|
|
|
|
|
emitter.onNext(AddTimeWatermark(resource, String.valueOf(userLevel)));
|
|
|
|
|
}
|
|
|
|
|
}).subscribeOn(Schedulers.newThread())
|
|
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
.subscribe(new Observer<Bitmap>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSubscribe(Disposable d) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onNext(Bitmap bitmap) {
|
|
|
|
|
BitmapDrawable drawable = new BitmapDrawable(bitmap);
|
|
|
|
|
if (callback != null) {
|
|
|
|
|
callback.onLoadSuccess(drawable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onError(Throwable e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onComplete() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
|
|
|
|
if (callback != null) {
|
|
|
|
|
@@ -434,6 +472,8 @@ public class LiveTextRender {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void renderTMP(Context context, final TextView textView, final LiveChatBean bean) {
|
|
|
|
|
final LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
|
|
|
|
|
|
|
|
|
|
@@ -454,7 +494,7 @@ public class LiveTextRender {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (textView != null) {
|
|
|
|
|
getLevelImage(context, bean.getLevel(), bean.isAnchor(), new ImgLoader.DrawableCallback() {
|
|
|
|
|
getLevelImage(context, bean.getLevel(), new ImgLoader.DrawableCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onLoadSuccess(Drawable drawable) {
|
|
|
|
|
SpannableStringBuilder builder = createPrefix(drawable, bean);
|
|
|
|
|
|