feat:完成家族小秘书消息对接(和之前的家族逻辑一样,只是协议码不对)
fix:修复公会小秘书消息文案展示不完整问题
This commit is contained in:
@@ -2,6 +2,8 @@ package com.chwl.app.ui.im;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.chwl.app.module_hall.im.msgholder.FamilyMsgViewHolder;
|
||||
import com.chwl.core.module_hall.im.FamilyAttachment;
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.api.model.contact.ContactEventListener;
|
||||
import com.netease.nim.uikit.api.model.session.SessionCustomization;
|
||||
@@ -144,6 +146,8 @@ public class ImInitHelper {
|
||||
HallDataManager.get().mainNimOnCreate();
|
||||
//公会模块
|
||||
NimUIKit.registerMsgItemViewHolder(ClanAttachment.class, ClanMsgViewHolder.class);
|
||||
//家族模块
|
||||
NimUIKit.registerMsgItemViewHolder(FamilyAttachment.class, FamilyMsgViewHolder.class);
|
||||
//瓜分钻石 三级
|
||||
NimUIKit.registerMsgItemViewHolder(CarveUpGoldThirdLevelAttachment.class, MsgViewHolderText.class);
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/sure_to_agree_user_join_room"
|
||||
android:textColor="@color/text_title_color"
|
||||
|
@@ -2,6 +2,7 @@ package com.chwl.app.module_hall.im;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.chwl.core.module_hall.im.FamilyImMsgInfo;
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.msg.MsgService;
|
||||
@@ -25,6 +26,23 @@ import io.reactivex.SingleOnSubscribe;
|
||||
*/
|
||||
|
||||
public class NimHelper {
|
||||
|
||||
/**
|
||||
* 更新家族消息到本地数据库
|
||||
*
|
||||
* @param uuid 消息 UUID
|
||||
* @param info 家族消息实体
|
||||
*/
|
||||
public static void updateFamilyMsgInfoMessage(String uuid, FamilyImMsgInfo info) {
|
||||
IMMessage message = IMNetEaseManager.get().queryMessageByUuid(uuid);
|
||||
if (message != null) {
|
||||
Map<String, Object> localExtension = FamilyImMsgInfo.convertToMap(info);
|
||||
message.setLocalExtension(localExtension);
|
||||
NIMClient.getService(MsgService.class)
|
||||
.updateIMMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模厅消息到本地数据库
|
||||
*
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.chwl.app.module_hall.im.msgholder;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
@@ -15,6 +16,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.coorchice.library.SuperTextView;
|
||||
import com.example.lib_utils.spannable.SpannableTextBuilder;
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
@@ -144,60 +146,33 @@ public class ClanMsgViewHolder extends MsgViewHolderBase{
|
||||
// content
|
||||
List<HallMsgComponent> erbanSysMsgLayoutContent = hallMsgLayout.getContents();
|
||||
if (erbanSysMsgLayoutContent != null) {
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
|
||||
SpannableTextBuilder textBuilder = new SpannableTextBuilder(tvContent);
|
||||
for (HallMsgComponent component : erbanSysMsgLayoutContent) {
|
||||
int start = spannableStringBuilder.length();
|
||||
String msgBody = component.getContent();
|
||||
if (Objects.equals(msgBody, "/r/n")) {
|
||||
msgBody = "\r\n";
|
||||
spannableStringBuilder.append(msgBody);
|
||||
textBuilder.appendText(msgBody,null,null,null,null,null,null);
|
||||
continue;
|
||||
}
|
||||
spannableStringBuilder.append(msgBody);
|
||||
Integer textColor = null;
|
||||
Integer textSize = null;
|
||||
Integer textStyle = null;
|
||||
if (component.getFontColor() != null) {
|
||||
try {
|
||||
spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor(component.getFontColor())),
|
||||
start, spannableStringBuilder.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
textColor = Color.parseColor(component.getFontColor());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (component.getFontSize() > 0) {
|
||||
spannableStringBuilder.setSpan(
|
||||
new MetricAffectingSpan() {
|
||||
@Override
|
||||
public void updateMeasureState(TextPaint p) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
tp.setTextSize(TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
component.getFontSize(),
|
||||
tvContent.getContext().getResources().getDisplayMetrics()));
|
||||
}
|
||||
},
|
||||
start, spannableStringBuilder.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
textSize = (int) component.getFontSize();
|
||||
}
|
||||
spannableStringBuilder.setSpan(
|
||||
new MetricAffectingSpan() {
|
||||
@Override
|
||||
public void updateMeasureState(TextPaint p) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
tp.setFakeBoldText(component.isFontBold());
|
||||
}
|
||||
},
|
||||
start, spannableStringBuilder.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
if (component.isFontBold()) {
|
||||
textStyle = Typeface.BOLD;
|
||||
}
|
||||
textBuilder.appendText(msgBody, textColor, null, textSize, textStyle, null, null);
|
||||
}
|
||||
tvContent.setText(spannableStringBuilder);
|
||||
textBuilder.apply();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,228 @@
|
||||
package com.chwl.app.module_hall.im.msgholder;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.module_hall.im.NimHelper;
|
||||
import com.chwl.app.ui.im.RouterHandler;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.module_hall.hall.HallModel;
|
||||
import com.chwl.core.module_hall.hall.bean.ApplyResult;
|
||||
import com.chwl.core.module_hall.im.FamilyAttachment;
|
||||
import com.chwl.core.module_hall.im.FamilyImMsgInfo;
|
||||
import com.chwl.core.module_hall.im.bean.HallMsgComponent;
|
||||
import com.chwl.core.module_hall.im.bean.HallMsgLayout;
|
||||
import com.chwl.core.utils.net.BeanObserver;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.coorchice.library.SuperTextView;
|
||||
import com.example.lib_utils.spannable.SpannableTextBuilder;
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* 模厅im消息展示
|
||||
* Created by lvzebiao on 2019/1/7.
|
||||
*/
|
||||
@Keep
|
||||
public class FamilyMsgViewHolder extends MsgViewHolderBase {
|
||||
|
||||
private ConstraintLayout clContainer;
|
||||
private TextView tvTitle;
|
||||
private AppCompatTextView stvAgree;
|
||||
private TextView tvContent;
|
||||
private View llOpLayout;
|
||||
private SuperTextView stvReject;
|
||||
private View llResultLayout;
|
||||
private SuperTextView tvResult;
|
||||
|
||||
public FamilyMsgViewHolder(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentResId() {
|
||||
return R.layout.layout_hall_msg_view_holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inflateContentView() {
|
||||
tvTitle = findViewById(R.id.tv_title);
|
||||
stvAgree = findViewById(R.id.stv_agree);
|
||||
stvReject = findViewById(R.id.stv_reject);
|
||||
llOpLayout = findViewById(R.id.ll_op_layout);
|
||||
tvContent = findViewById(R.id.tv_content);
|
||||
clContainer = findViewById(R.id.cl_container);
|
||||
llResultLayout = findViewById(R.id.ll_result_layout);
|
||||
tvResult = findViewById(R.id.tv_result);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
clContainer.getLayoutParams().width = ScreenUtil.screenWidth * 240 / 375;
|
||||
clContainer.setVisibility(View.GONE);
|
||||
clContainer.setClickable(false);
|
||||
if (message == null) {
|
||||
return;
|
||||
}
|
||||
IMMessage imMessage = IMNetEaseManager.get().queryMessageByUuid(message.getUuid());
|
||||
if (imMessage == null || imMessage.getAttachment() == null) {
|
||||
return;
|
||||
}
|
||||
if (!(imMessage.getAttachment() instanceof FamilyAttachment)) {
|
||||
return;
|
||||
}
|
||||
FamilyAttachment attachment = (FamilyAttachment) imMessage.getAttachment();
|
||||
FamilyImMsgInfo info = attachment.getFamilyImMsgInfo();
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
if (message.getLocalExtension() != null) {
|
||||
info = FamilyImMsgInfo.convertMapToObject(message.getLocalExtension());
|
||||
}
|
||||
clContainer.setVisibility(View.VISIBLE);
|
||||
if (info.getRouterType() > 0) {
|
||||
final int routerType = info.getRouterType();
|
||||
final String routerValue = info.getRouterValue();
|
||||
clContainer.setClickable(true);
|
||||
clContainer.setOnClickListener(v ->
|
||||
RouterHandler.handle(context, routerType, routerValue));
|
||||
}
|
||||
stvReject.setVisibility(View.VISIBLE);
|
||||
int second = attachment.getSecond();
|
||||
if (second == CustomAttachment.CUSTOM_MSG_FAMILY_INVITE
|
||||
|| second == CustomAttachment.CUSTOM_MSG_FAMILY_APPLY) {
|
||||
setMsgTypeView(info, second);
|
||||
} else {
|
||||
llResultLayout.setVisibility(View.GONE);
|
||||
llOpLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
HallMsgLayout hallMsgLayout = null;
|
||||
try {
|
||||
String layout = info.getLayout();
|
||||
if (!TextUtils.isEmpty(layout)) {
|
||||
hallMsgLayout = JSON.parseObject(layout, HallMsgLayout.class);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (hallMsgLayout == null) {
|
||||
tvTitle.setText("");
|
||||
tvContent.setText("");
|
||||
return;
|
||||
}
|
||||
// title
|
||||
tvTitle.setText(hallMsgLayout.getTitle().getContent());
|
||||
// content
|
||||
List<HallMsgComponent> erbanSysMsgLayoutContent = hallMsgLayout.getContents();
|
||||
if (erbanSysMsgLayoutContent != null) {
|
||||
SpannableTextBuilder textBuilder = new SpannableTextBuilder(tvContent);
|
||||
for (HallMsgComponent component : erbanSysMsgLayoutContent) {
|
||||
String msgBody = component.getContent();
|
||||
if (Objects.equals(msgBody, "/r/n")) {
|
||||
msgBody = "\r\n";
|
||||
textBuilder.appendText(msgBody,null,null,null,null,null,null);
|
||||
continue;
|
||||
}
|
||||
Integer textColor = null;
|
||||
Integer textSize = null;
|
||||
Integer textStyle = null;
|
||||
if (component.getFontColor() != null) {
|
||||
try {
|
||||
textColor = Color.parseColor(component.getFontColor());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (component.getFontSize() > 0) {
|
||||
textSize = (int) component.getFontSize();
|
||||
}
|
||||
if (component.isFontBold()) {
|
||||
textStyle = Typeface.BOLD;
|
||||
}
|
||||
textBuilder.appendText(msgBody, textColor, null, textSize, textStyle, null, null);
|
||||
}
|
||||
textBuilder.apply();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleClick(FamilyImMsgInfo info, int second) {
|
||||
stvAgree.setOnClickListener(view -> {
|
||||
handleApply(info, second, 1);
|
||||
});
|
||||
stvReject.setOnClickListener(view -> {
|
||||
handleApply(info, second, 0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type 1同意,0拒绝
|
||||
*/
|
||||
private void handleApply(FamilyImMsgInfo info, int second, int type) {
|
||||
HallModel.get().dealApply(info.getUrl(), type)
|
||||
.subscribe(new BeanObserver<>() {
|
||||
@Override
|
||||
public void onErrorMsg(String error) {
|
||||
SingleToastUtil.showToast(error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ApplyResult result) {
|
||||
if (result.getCode() == ApplyResult.CODE_MSG_OUT_OF_DATE) {
|
||||
info.setType(FamilyImMsgInfo.MSG_TYPE_OUT_OF_DATE);
|
||||
} else if (result.getCode() == ApplyResult.CODE_MSG_HAS_HANDLE) {
|
||||
info.setType(FamilyImMsgInfo.MSG_TYPE_HAS_HANDLE);
|
||||
} else {
|
||||
info.setType(type == 1 ? FamilyImMsgInfo.MSG_TYPE_HAS_AGREE :
|
||||
FamilyImMsgInfo.MSG_TYPE_HAS_REJECT);
|
||||
}
|
||||
setMsgTypeView(info, second);
|
||||
Map<String, Object> localExtension = FamilyImMsgInfo.convertToMap(info);
|
||||
message.setLocalExtension(localExtension);
|
||||
updateMessageToLocal(info);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateMessageToLocal(FamilyImMsgInfo info) {
|
||||
NimHelper.updateFamilyMsgInfoMessage(message.getUuid(), info);
|
||||
}
|
||||
|
||||
private void setMsgTypeView(FamilyImMsgInfo info, int second) {
|
||||
llResultLayout.setVisibility(View.VISIBLE);
|
||||
llOpLayout.setVisibility(View.GONE);
|
||||
if (info.getType() == FamilyImMsgInfo.MSG_TYPE_HAS_AGREE) {
|
||||
tvResult.setText(ResUtil.getString(R.string.im_msgholder_hallmsgviewholder_01));
|
||||
} else if (info.getType() == FamilyImMsgInfo.MSG_TYPE_HAS_REJECT) {
|
||||
tvResult.setText(ResUtil.getString(R.string.im_msgholder_hallmsgviewholder_02));
|
||||
} else if (info.getType() == FamilyImMsgInfo.MSG_TYPE_OUT_OF_DATE) {
|
||||
tvResult.setText(ResUtil.getString(R.string.im_msgholder_hallmsgviewholder_03));
|
||||
} else if (info.getType() == FamilyImMsgInfo.MSG_TYPE_HAS_HANDLE) {
|
||||
tvResult.setText(ResUtil.getString(R.string.im_msgholder_hallmsgviewholder_04));
|
||||
} else {
|
||||
llResultLayout.setVisibility(View.GONE);
|
||||
llOpLayout.setVisibility(View.VISIBLE);
|
||||
handleClick(info, second);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
package com.chwl.app.module_hall.im.msgholder;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
@@ -16,6 +17,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.coorchice.library.SuperTextView;
|
||||
import com.example.lib_utils.spannable.SpannableTextBuilder;
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
@@ -155,60 +157,32 @@ public class HallMsgViewHolder extends MsgViewHolderBase {
|
||||
// content
|
||||
List<HallMsgComponent> erbanSysMsgLayoutContent = hallMsgLayout.getContents();
|
||||
if (erbanSysMsgLayoutContent != null) {
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
|
||||
SpannableTextBuilder textBuilder = new SpannableTextBuilder(tvContent);
|
||||
for (HallMsgComponent component : erbanSysMsgLayoutContent) {
|
||||
int start = spannableStringBuilder.length();
|
||||
String msgBody = component.getContent();
|
||||
if (Objects.equals(msgBody, "/r/n")) {
|
||||
msgBody = "\r\n";
|
||||
spannableStringBuilder.append(msgBody);
|
||||
textBuilder.appendText(msgBody,null,null,null,null,null,null);
|
||||
continue;
|
||||
}
|
||||
spannableStringBuilder.append(msgBody);
|
||||
}Integer textColor = null;
|
||||
Integer textSize = null;
|
||||
Integer textStyle = null;
|
||||
if (component.getFontColor() != null) {
|
||||
try {
|
||||
spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.parseColor(component.getFontColor())),
|
||||
start, spannableStringBuilder.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
textColor = Color.parseColor(component.getFontColor());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (component.getFontSize() > 0) {
|
||||
spannableStringBuilder.setSpan(
|
||||
new MetricAffectingSpan() {
|
||||
@Override
|
||||
public void updateMeasureState(TextPaint p) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
tp.setTextSize(TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
component.getFontSize(),
|
||||
tvContent.getContext().getResources().getDisplayMetrics()));
|
||||
}
|
||||
},
|
||||
start, spannableStringBuilder.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
textSize = (int) component.getFontSize();
|
||||
}
|
||||
spannableStringBuilder.setSpan(
|
||||
new MetricAffectingSpan() {
|
||||
@Override
|
||||
public void updateMeasureState(TextPaint p) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
tp.setFakeBoldText(component.isFontBold());
|
||||
}
|
||||
},
|
||||
start, spannableStringBuilder.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
if (component.isFontBold()) {
|
||||
textStyle = Typeface.BOLD;
|
||||
}
|
||||
textBuilder.appendText(msgBody, textColor, null, textSize, textStyle, null, null);
|
||||
}
|
||||
tvContent.setText(spannableStringBuilder);
|
||||
textBuilder.apply();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -19,6 +19,15 @@ import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_DRAW_GIFT
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_LEVEL_UP;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_LEVEL_UP_NOTICE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAMILY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAMILY_CREATE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAMILY_DISMISS;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAMILY_INVITE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAMILY_APPLY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAMILY_DEAL_APPLY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAMILY_DEAL_INVITE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAMILY_REMOVE_MEMBER;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAMILY_SET_MANAGER;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_MEMBER_COUNT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_ROOM_NOTIFY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_TOPIC;
|
||||
@@ -116,6 +125,7 @@ import com.chwl.core.miniworld.bean.MWChatMemberCountAttachment;
|
||||
import com.chwl.core.miniworld.bean.MWChatTopicAttachment;
|
||||
import com.chwl.core.miniworld.bean.OpenAudioPartyAttachment;
|
||||
import com.chwl.core.module_hall.im.ClanAttachment;
|
||||
import com.chwl.core.module_hall.im.FamilyAttachment;
|
||||
import com.chwl.core.public_chat_hall.attachment.AitFriendsAttachment;
|
||||
import com.chwl.core.public_chat_hall.attachment.AitMeAttachment;
|
||||
import com.chwl.core.room.bean.LeaveModeAttachment;
|
||||
@@ -379,6 +389,21 @@ public class CustomAttachParser implements MsgAttachmentParser {
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case CUSTOM_MSG_FAMILY:
|
||||
switch (second) {
|
||||
case CUSTOM_MSG_FAMILY_INVITE:
|
||||
case CUSTOM_MSG_FAMILY_DEAL_INVITE:
|
||||
case CUSTOM_MSG_FAMILY_APPLY:
|
||||
case CUSTOM_MSG_FAMILY_DEAL_APPLY:
|
||||
case CUSTOM_MSG_FAMILY_SET_MANAGER:
|
||||
case CUSTOM_MSG_FAMILY_REMOVE_MEMBER:
|
||||
case CUSTOM_MSG_FAMILY_CREATE:
|
||||
case CUSTOM_MSG_FAMILY_DISMISS:
|
||||
attachment = new FamilyAttachment(second);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case CUSTOM_MSG_CLAN:
|
||||
switch (second) {
|
||||
|
@@ -503,6 +503,20 @@ public class CustomAttachment implements MsgAttachment {
|
||||
// 头条-更新
|
||||
public static final int CUSTOM_MSG_HEADLINE_CHANGED = 108;
|
||||
public static final int CUSTOM_MSG_HEADLINE_CHANGED_SUB = 1081;
|
||||
|
||||
/**
|
||||
* 家族
|
||||
*/
|
||||
public static final int CUSTOM_MSG_FAMILY = 110;
|
||||
public static final int CUSTOM_MSG_FAMILY_INVITE = 1101;
|
||||
public static final int CUSTOM_MSG_FAMILY_DEAL_INVITE = 1102;
|
||||
public static final int CUSTOM_MSG_FAMILY_APPLY = 1103;
|
||||
public static final int CUSTOM_MSG_FAMILY_DEAL_APPLY = 1104;
|
||||
public static final int CUSTOM_MSG_FAMILY_SET_MANAGER = 1105;
|
||||
public static final int CUSTOM_MSG_FAMILY_REMOVE_MEMBER = 1106;
|
||||
public static final int CUSTOM_MSG_FAMILY_CREATE = 1107;
|
||||
public static final int CUSTOM_MSG_FAMILY_DISMISS = 1108;
|
||||
|
||||
/**
|
||||
* 自定义消息附件的类型,根据该字段区分不同的自定义消息
|
||||
*/
|
||||
|
@@ -0,0 +1,49 @@
|
||||
package com.chwl.core.module_hall.im;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* 模厅消息
|
||||
* Created by lvzebiao on 2019/1/7.
|
||||
*/
|
||||
@Keep
|
||||
public class FamilyAttachment extends CustomAttachment {
|
||||
|
||||
private FamilyImMsgInfo familyImMsgInfo;
|
||||
|
||||
public FamilyAttachment() {
|
||||
this(CUSTOM_MSG_FAMILY);
|
||||
}
|
||||
|
||||
public FamilyAttachment(int second) {
|
||||
super(CUSTOM_MSG_FAMILY, second);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseData(JSONObject data) {
|
||||
try {
|
||||
familyImMsgInfo = new Gson().fromJson(data.toJSONString(), FamilyImMsgInfo.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject packData() {
|
||||
try {
|
||||
String jsonStr = new Gson().toJson(familyImMsgInfo);
|
||||
return JSONObject.parseObject(jsonStr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new JSONObject();
|
||||
}
|
||||
}
|
||||
|
||||
public FamilyImMsgInfo getFamilyImMsgInfo() {
|
||||
return familyImMsgInfo;
|
||||
}
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
package com.chwl.core.module_hall.im;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Created by lvzebiao on 2019/1/8.
|
||||
*/
|
||||
@Keep
|
||||
@Data
|
||||
public class FamilyImMsgInfo implements Serializable{
|
||||
|
||||
/**
|
||||
* 已过期
|
||||
*/
|
||||
public final static int MSG_TYPE_OUT_OF_DATE = 1;
|
||||
/**
|
||||
* 已处理
|
||||
*/
|
||||
public final static int MSG_TYPE_HAS_HANDLE = 2;
|
||||
/**
|
||||
* 已同意
|
||||
*/
|
||||
public final static int MSG_TYPE_HAS_AGREE = 3;
|
||||
/**
|
||||
* 已拒绝
|
||||
*/
|
||||
public final static int MSG_TYPE_HAS_REJECT = 4;
|
||||
|
||||
private String url;
|
||||
private int type;
|
||||
/**后台给的显示内容*/
|
||||
private String layout;
|
||||
/**{@link com.chwl.core.im.custom.bean.RouterType}*/
|
||||
private int routerType;
|
||||
|
||||
private String routerValue;
|
||||
|
||||
public static Map<String, Object> convertToMap(FamilyImMsgInfo info) {
|
||||
Map<String, Object> localExtension = new HashMap<>();
|
||||
localExtension.put("url", info.getUrl());
|
||||
localExtension.put("type", info.getType());
|
||||
localExtension.put("layout", info.getLayout());
|
||||
localExtension.put("routerType", info.getRouterType());
|
||||
localExtension.put("routerValue", info.getRouterValue());
|
||||
return localExtension;
|
||||
}
|
||||
|
||||
public static FamilyImMsgInfo convertMapToObject(Map<String, Object> localExtension) {
|
||||
FamilyImMsgInfo info = new FamilyImMsgInfo();
|
||||
if (localExtension != null) {
|
||||
info.setUrl((String) localExtension.get("url"));
|
||||
info.setType((Integer) localExtension.get("type"));
|
||||
info.setLayout((String) localExtension.get("layout"));
|
||||
Object routerType = localExtension.get("routerType");
|
||||
if (routerType != null) {
|
||||
info.setRouterType((Integer) routerType);
|
||||
}
|
||||
Object routerValue = localExtension.get("routerValue");
|
||||
if (routerValue != null) {
|
||||
info.setRouterValue((String) routerValue);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user