diff --git a/app/src/main/java/com/chwl/app/ui/im/ImInitHelper.java b/app/src/main/java/com/chwl/app/ui/im/ImInitHelper.java index 67e1abeae..edfd74bd3 100644 --- a/app/src/main/java/com/chwl/app/ui/im/ImInitHelper.java +++ b/app/src/main/java/com/chwl/app/ui/im/ImInitHelper.java @@ -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); diff --git a/app/src/main/res/layout/layout_agree_apply_dialog.xml b/app/src/main/res/layout/layout_agree_apply_dialog.xml index 42ecfaa3a..27bdd3ed0 100644 --- a/app/src/main/res/layout/layout_agree_apply_dialog.xml +++ b/app/src/main/res/layout/layout_agree_apply_dialog.xml @@ -33,7 +33,7 @@ localExtension = FamilyImMsgInfo.convertToMap(info); + message.setLocalExtension(localExtension); + NIMClient.getService(MsgService.class) + .updateIMMessage(message); + } + } + /** * 更新模厅消息到本地数据库 * diff --git a/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/ClanMsgViewHolder.java b/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/ClanMsgViewHolder.java index e8490c555..94379586a 100644 --- a/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/ClanMsgViewHolder.java +++ b/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/ClanMsgViewHolder.java @@ -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 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(); } } diff --git a/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/FamilyMsgViewHolder.java b/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/FamilyMsgViewHolder.java new file mode 100644 index 000000000..e2d73d161 --- /dev/null +++ b/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/FamilyMsgViewHolder.java @@ -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 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 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); + } + } + +} \ No newline at end of file diff --git a/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/HallMsgViewHolder.java b/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/HallMsgViewHolder.java index 784b179f6..01078e962 100644 --- a/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/HallMsgViewHolder.java +++ b/app/src/module_labour_union/java/com/chwl/app/module_hall/im/msgholder/HallMsgViewHolder.java @@ -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 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(); } } diff --git a/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachParser.java b/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachParser.java index ac66554f1..e207a0950 100644 --- a/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachParser.java +++ b/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachParser.java @@ -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) { diff --git a/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachment.java b/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachment.java index a6ff70e1c..4d19ed46b 100644 --- a/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachment.java +++ b/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachment.java @@ -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; + /** * 自定义消息附件的类型,根据该字段区分不同的自定义消息 */ diff --git a/core/src/model_labour_union/java/com/chwl/core/module_hall/im/FamilyAttachment.java b/core/src/model_labour_union/java/com/chwl/core/module_hall/im/FamilyAttachment.java new file mode 100644 index 000000000..c6f51f45c --- /dev/null +++ b/core/src/model_labour_union/java/com/chwl/core/module_hall/im/FamilyAttachment.java @@ -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; + } +} diff --git a/core/src/model_labour_union/java/com/chwl/core/module_hall/im/FamilyImMsgInfo.java b/core/src/model_labour_union/java/com/chwl/core/module_hall/im/FamilyImMsgInfo.java new file mode 100644 index 000000000..b570e788f --- /dev/null +++ b/core/src/model_labour_union/java/com/chwl/core/module_hall/im/FamilyImMsgInfo.java @@ -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 convertToMap(FamilyImMsgInfo info) { + Map 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 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; + } + +}