超皇字体颜色
This commit is contained in:
parent
f8826d0239
commit
82ccf66d80
@ -213,6 +213,52 @@ public class IMLoginModel extends BaseModel {
|
||||
@SerializedName("mount_effect")
|
||||
private boolean mountEffect = false;
|
||||
|
||||
//超皇昵称渐变色上
|
||||
@SerializedName("startColor")
|
||||
private String startColor = "";
|
||||
//超皇昵称渐变色下
|
||||
@SerializedName("endColor")
|
||||
private String endColor = "";
|
||||
//超皇字体颜色
|
||||
@SerializedName("contentColor")
|
||||
private String contentColor = "";
|
||||
|
||||
public String getNobleEndTime() {
|
||||
return nobleEndTime;
|
||||
}
|
||||
|
||||
public IMLoginModel setNobleEndTime(String nobleEndTime) {
|
||||
this.nobleEndTime = nobleEndTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStartColor() {
|
||||
return startColor;
|
||||
}
|
||||
|
||||
public IMLoginModel setStartColor(String startColor) {
|
||||
this.startColor = startColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEndColor() {
|
||||
return endColor;
|
||||
}
|
||||
|
||||
public IMLoginModel setEndColor(String endColor) {
|
||||
this.endColor = endColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getContentColor() {
|
||||
return contentColor;
|
||||
}
|
||||
|
||||
public IMLoginModel setContentColor(String contentColor) {
|
||||
this.contentColor = contentColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMountEffect() {
|
||||
return mountEffect;
|
||||
}
|
||||
|
@ -49,6 +49,42 @@ public class LiveChatBean {
|
||||
|
||||
@SerializedName("bubbleSrc")
|
||||
private String bubbleSrc = "";
|
||||
//超皇昵称渐变色上
|
||||
@SerializedName("startColor")
|
||||
private String startColor = "";
|
||||
//超皇昵称渐变色下
|
||||
@SerializedName("endColor")
|
||||
private String endColor = "";
|
||||
//超皇字体颜色
|
||||
@SerializedName("contentColor")
|
||||
private String contentColor = "";
|
||||
|
||||
public String getStartColor() {
|
||||
return startColor;
|
||||
}
|
||||
|
||||
public LiveChatBean setStartColor(String startColor) {
|
||||
this.startColor = startColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEndColor() {
|
||||
return endColor;
|
||||
}
|
||||
|
||||
public LiveChatBean setEndColor(String endColor) {
|
||||
this.endColor = endColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getContentColor() {
|
||||
return contentColor;
|
||||
}
|
||||
|
||||
public LiveChatBean setContentColor(String contentColor) {
|
||||
this.contentColor = contentColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNobleId() {
|
||||
return nobleId;
|
||||
|
@ -5,10 +5,13 @@ import android.util.Log;
|
||||
import com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
@ -79,6 +82,7 @@ public class SocketRyChatUtil {
|
||||
*/
|
||||
public static void sendChatMessage(String mLiveUid, String content, boolean isAnchor, int userType, int guardType) {
|
||||
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||||
IMLoginModel model = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
|
||||
if (u == null) {
|
||||
return;
|
||||
}
|
||||
@ -103,7 +107,12 @@ public class SocketRyChatUtil {
|
||||
.param("medal_name", u.getMedalName())
|
||||
.param("medal_level", u.getMedalLevel())
|
||||
.param("good_num", u.getGoodnum())
|
||||
.param("ct", content);
|
||||
.param("ct", content)
|
||||
.param("noble_id", String.valueOf(model.getNobleId()))
|
||||
.param("contentColor", String.valueOf(model.getContentColor()))
|
||||
.param("startColor", String.valueOf(model.getStartColor()))
|
||||
.param("endColor", String.valueOf(model.getEndColor()))
|
||||
;
|
||||
msg.create();
|
||||
|
||||
String targetId = "g" + mLiveUid;
|
||||
|
@ -605,6 +605,10 @@ public class SocketRyClient {
|
||||
chatBean.setVipType(map.getIntValue("vip_type"));
|
||||
chatBean.setMedal_honor(map.getString("medal_honor"));
|
||||
chatBean.setGood_nub(map.getString("good_num"));
|
||||
chatBean.setNobleId(map.getString("noble_id"));//貴族ID
|
||||
chatBean.setStartColor(map.getString("startColor"));//昵称开始颜色
|
||||
chatBean.setEndColor(map.getString("endColor"));//昵称结束颜色
|
||||
chatBean.setContentColor(map.getString("contentColor"));//文字内容颜色
|
||||
if (!map.getString("guard_type").equals("undefined")) {
|
||||
chatBean.setGuardType(map.getIntValue("guard_type"));
|
||||
}
|
||||
@ -660,6 +664,9 @@ public class SocketRyClient {
|
||||
chatBean.setContent(WordUtil.getString(R.string.live_enter_room));
|
||||
chatBean.setGuardType(obj.getIntValue("guard_type"));
|
||||
chatBean.setNobleId(obj.getString("noble_id"));//貴族ID
|
||||
chatBean.setStartColor(obj.getString("startColor"));//昵称开始颜色
|
||||
chatBean.setEndColor(obj.getString("endColor"));//昵称结束颜色
|
||||
chatBean.setContentColor(obj.getString("contentColor"));//文字内容颜色
|
||||
chatBean.setNobleIcon(obj.getString("noble_icon"));//貴族圖標
|
||||
chatBean.setBubbleSrc(obj.getString("bubbleSrc"));//氣泡
|
||||
//增加粉丝徽章信息
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.yunbao.live.utils;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Shader;
|
||||
import android.text.style.ReplacementSpan;
|
||||
|
||||
/**
|
||||
* 渐变色
|
||||
*/
|
||||
public class LinearGradientFontSpan extends ReplacementSpan {
|
||||
private int mSize;
|
||||
private int startColor;
|
||||
private int endColor;
|
||||
|
||||
|
||||
public LinearGradientFontSpan(int startColor, int endColor) {
|
||||
this.startColor = startColor;
|
||||
this.endColor = endColor;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
|
||||
mSize = (int) (paint.measureText(text, start, end));
|
||||
|
||||
//这段不可以去掉,字体高度没设置,可能出现draw()方法没有被调用,如果你调用SpannableStringBuilder后append一个字符串,效果也是会出来,下面这段就不需要了
|
||||
// 原因详见https://stackoverflow.com/questions/20069537/replacementspans-draw-method-isnt-called
|
||||
Paint.FontMetricsInt metrics = paint.getFontMetricsInt();
|
||||
if (fm != null) {
|
||||
fm.top = metrics.top;
|
||||
fm.ascent = metrics.ascent;
|
||||
fm.descent = metrics.descent;
|
||||
fm.bottom = metrics.bottom;
|
||||
}
|
||||
|
||||
return mSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
|
||||
LinearGradient lg = new LinearGradient(0, 0, 0, paint.descent() - paint.ascent(),
|
||||
startColor,
|
||||
endColor,
|
||||
Shader.TileMode.REPEAT); //从上到下渐变
|
||||
paint.setShader(lg);
|
||||
|
||||
canvas.drawText(text, start, end, x, y, paint);//绘制文字
|
||||
}
|
||||
|
||||
}
|
@ -108,7 +108,7 @@ public class LiveTextRender {
|
||||
|
||||
if (gzDrawables != null) {//贵族
|
||||
builder.append(" ");
|
||||
gzDrawables.setBounds(0, 0, DpUtil.dp2px(18), DpUtil.dp2px(18));
|
||||
gzDrawables.setBounds(0, 0, DpUtil.dp2px(32), DpUtil.dp2px(18));
|
||||
builder.setSpan(new VerticalImageSpan(gzDrawables), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
index += 2;
|
||||
}
|
||||
@ -159,15 +159,6 @@ public class LiveTextRender {
|
||||
}
|
||||
|
||||
|
||||
// if (bean.getVipType() != 0) {//vip图标
|
||||
// Drawable vipDrawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_vip);
|
||||
// if (vipDrawable != null) {
|
||||
// builder.append(" ");
|
||||
// vipDrawable.setBounds(0, 0, DpUtil.dp2px(28), DpUtil.dp2px(14));
|
||||
// builder.setSpan(new VerticalImageSpan(vipDrawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
// index += 2;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
if (bean.isManager()) {//直播间管理员图标
|
||||
@ -265,7 +256,7 @@ public class LiveTextRender {
|
||||
}
|
||||
|
||||
public static void gz(final Context context, final TextView textView, final LiveChatBean bean) {
|
||||
ImgLoader.displayDrawable(context, bean.getMedal(), new ImgLoader.DrawableCallback() {
|
||||
ImgLoader.displayDrawable(context, bean.getMedal_new(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
gzDrawables = null;
|
||||
@ -344,8 +335,18 @@ public class LiveTextRender {
|
||||
name += ":";
|
||||
}
|
||||
builder.append(name);
|
||||
builder.setSpan(new ForegroundColorSpan(color), length, length + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
//超皇设置渐变色展示昵称
|
||||
if (TextUtils.equals("7",bean.getNobleId())){
|
||||
builder.setSpan(new LinearGradientFontSpan(Color.parseColor(bean.getStartColor()), Color.parseColor(bean.getEndColor())), length, length + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}else {
|
||||
builder.setSpan(new ForegroundColorSpan(color), length, length + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
int lengthContent = builder.length();
|
||||
builder.append(bean.getContent());
|
||||
//超皇设置渐变色展示昵称
|
||||
if (TextUtils.equals("7",bean.getNobleId())){
|
||||
builder.setSpan(new ForegroundColorSpan(Color.parseColor(bean.getContentColor())), lengthContent, lengthContent + bean.getContent().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
if (bean.getType() == LiveChatBean.LIGHT) {
|
||||
Drawable heartDrawable = ContextCompat.getDrawable(CommonAppContext.sInstance, LiveIconUtil.getLiveLightIcon(bean.getHeart()));
|
||||
if (heartDrawable != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user