|
@@ -1,5 +1,6 @@
|
|
package com.tencent.qcloud.tim.uikit.modules.chat.layout.message.holder;
|
|
package com.tencent.qcloud.tim.uikit.modules.chat.layout.message.holder;
|
|
|
|
|
|
|
|
+import android.graphics.drawable.NinePatchDrawable;
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
import android.view.Gravity;
|
|
import android.view.Gravity;
|
|
@@ -13,14 +14,24 @@ import com.bumptech.glide.Glide;
|
|
import com.opensource.svgaplayer.SVGADrawable;
|
|
import com.opensource.svgaplayer.SVGADrawable;
|
|
import com.opensource.svgaplayer.SVGAImageView;
|
|
import com.opensource.svgaplayer.SVGAImageView;
|
|
import com.swago.baseswago.util.AppContext;
|
|
import com.swago.baseswago.util.AppContext;
|
|
|
|
+import com.swago.baseswago.util.DianJiuUtil;
|
|
|
|
+import com.swago.baseswago.util.StringUtils;
|
|
import com.swago.baseswago.util.UserInfo;
|
|
import com.swago.baseswago.util.UserInfo;
|
|
|
|
+import com.tencent.imsdk.message.CustomElement;
|
|
|
|
+import com.tencent.imsdk.v2.V2TIMCustomElem;
|
|
import com.tencent.imsdk.v2.V2TIMMessage;
|
|
import com.tencent.imsdk.v2.V2TIMMessage;
|
|
import com.tencent.qcloud.tim.uikit.R;
|
|
import com.tencent.qcloud.tim.uikit.R;
|
|
import com.tencent.qcloud.tim.uikit.config.TUIKitConfigs;
|
|
import com.tencent.qcloud.tim.uikit.config.TUIKitConfigs;
|
|
import com.tencent.qcloud.tim.uikit.modules.message.MessageInfo;
|
|
import com.tencent.qcloud.tim.uikit.modules.message.MessageInfo;
|
|
import com.tencent.qcloud.tim.uikit.utils.ToastUtil;
|
|
import com.tencent.qcloud.tim.uikit.utils.ToastUtil;
|
|
|
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
import de.hdodenhof.circleimageview.CircleImageView;
|
|
import de.hdodenhof.circleimageview.CircleImageView;
|
|
|
|
+import kotlin.Unit;
|
|
|
|
+import kotlin.jvm.functions.Function1;
|
|
|
|
|
|
public abstract class MessageContentHolder extends MessageEmptyHolder {
|
|
public abstract class MessageContentHolder extends MessageEmptyHolder {
|
|
|
|
|
|
@@ -59,9 +70,13 @@ public abstract class MessageContentHolder extends MessageEmptyHolder {
|
|
if (msg.isSelf()) {
|
|
if (msg.isSelf()) {
|
|
leftUserIcon.setVisibility(View.GONE);
|
|
leftUserIcon.setVisibility(View.GONE);
|
|
rightUserIcon.setVisibility(View.VISIBLE);
|
|
rightUserIcon.setVisibility(View.VISIBLE);
|
|
|
|
+ leftSvgaImage.setVisibility(View.INVISIBLE);
|
|
|
|
+ rightSvgaImage.setVisibility(View.VISIBLE);
|
|
} else {
|
|
} else {
|
|
leftUserIcon.setVisibility(View.VISIBLE);
|
|
leftUserIcon.setVisibility(View.VISIBLE);
|
|
rightUserIcon.setVisibility(View.GONE);
|
|
rightUserIcon.setVisibility(View.GONE);
|
|
|
|
+ leftSvgaImage.setVisibility(View.VISIBLE);
|
|
|
|
+ rightSvgaImage.setVisibility(View.INVISIBLE);
|
|
}
|
|
}
|
|
|
|
|
|
//// 用户昵称设置
|
|
//// 用户昵称设置
|
|
@@ -121,13 +136,29 @@ public abstract class MessageContentHolder extends MessageEmptyHolder {
|
|
sendingProgress.setVisibility(View.GONE);
|
|
sendingProgress.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
|
|
|
|
- //// 聊天气泡设置
|
|
|
|
- if (msg.isSelf()) {
|
|
|
|
- if (properties.getRightBubble() != null && properties.getRightBubble().getConstantState() != null) {
|
|
|
|
- msgContentFrame.setBackground(properties.getRightBubble().getConstantState().newDrawable());
|
|
|
|
|
|
+ String customElem = msg.getTimMessage().toString();
|
|
|
|
+ List<JSONObject> customEle = StringUtils.INSTANCE.extractJsonObjects(customElem);
|
|
|
|
+ if (!customEle.isEmpty()){
|
|
|
|
+ String android_chat_special = customEle.get(0).optString("android_chat_special");
|
|
|
|
+ DianJiuUtil.INSTANCE.loadDian9Tu(AppContext.getContext(), android_chat_special, new Function1<NinePatchDrawable, Unit>() {
|
|
|
|
+ @Override
|
|
|
|
+ public Unit invoke(NinePatchDrawable ninePatchDrawable) {
|
|
|
|
+ if (ninePatchDrawable != null){
|
|
|
|
+ msgContentLinear.setBackground(ninePatchDrawable);
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ if (msg.isSelf()){
|
|
|
|
+ msgContentLinear.setBackgroundResource(R.drawable.bg_chat_purple);
|
|
} else {
|
|
} else {
|
|
- msgContentFrame.setBackgroundResource(R.drawable.bg_chat_purple);
|
|
|
|
|
|
+ msgContentLinear.setBackgroundResource(R.drawable.bg_chat_white);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //// 聊天气泡设置
|
|
|
|
+ if (msg.isSelf()) {
|
|
if (properties.getRightSvgaAvatar() != null){
|
|
if (properties.getRightSvgaAvatar() != null){
|
|
SVGADrawable drawable = new SVGADrawable(properties.getRightSvgaAvatar());
|
|
SVGADrawable drawable = new SVGADrawable(properties.getRightSvgaAvatar());
|
|
rightSvgaImage.setVisibility(View.VISIBLE);
|
|
rightSvgaImage.setVisibility(View.VISIBLE);
|
|
@@ -137,12 +168,6 @@ public abstract class MessageContentHolder extends MessageEmptyHolder {
|
|
rightSvgaImage.setVisibility(View.INVISIBLE);
|
|
rightSvgaImage.setVisibility(View.INVISIBLE);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if (properties.getLeftBubble() != null && properties.getLeftBubble().getConstantState() != null) {
|
|
|
|
- msgContentFrame.setBackground(properties.getLeftBubble().getConstantState().newDrawable());
|
|
|
|
- msgContentFrame.setLayoutParams(msgContentFrame.getLayoutParams());
|
|
|
|
- } else {
|
|
|
|
- msgContentFrame.setBackgroundResource(R.drawable.bg_chat_white);
|
|
|
|
- }
|
|
|
|
if (properties.getLeftSvgaAvatar() != null){
|
|
if (properties.getLeftSvgaAvatar() != null){
|
|
SVGADrawable drawable = new SVGADrawable(properties.getLeftSvgaAvatar());
|
|
SVGADrawable drawable = new SVGADrawable(properties.getLeftSvgaAvatar());
|
|
leftSvgaImage.setVisibility(View.VISIBLE);
|
|
leftSvgaImage.setVisibility(View.VISIBLE);
|