|
| 1 | +package com.netease.im.session.extension; |
| 2 | + |
| 3 | +import com.alibaba.fastjson.JSONObject; |
| 4 | +import com.facebook.react.bridge.Arguments; |
| 5 | +import com.facebook.react.bridge.WritableMap; |
| 6 | +import com.netease.im.MessageConstant; |
| 7 | + |
| 8 | +/** |
| 9 | + * Created by dowin on 2017/10/23. |
| 10 | + */ |
| 11 | + |
| 12 | +public class CardAttachment extends CustomAttachment { |
| 13 | + |
| 14 | + private String type; |
| 15 | + private String name; |
| 16 | + private String imgPath; |
| 17 | + private String sessionId; |
| 18 | + |
| 19 | + public CardAttachment() { |
| 20 | + super(CustomAttachmentType.Card); |
| 21 | + } |
| 22 | + |
| 23 | + @Override |
| 24 | + protected void parseData(JSONObject data) { |
| 25 | + type = data.getString(MessageConstant.Card.type); |
| 26 | + name = data.getString(MessageConstant.Card.name); |
| 27 | + imgPath = data.getString(MessageConstant.Card.imgPath); |
| 28 | + sessionId = data.getString(MessageConstant.Card.sessionId); |
| 29 | + } |
| 30 | + |
| 31 | + public void setParams(String type, String name, String imgPath, String sessionId) { |
| 32 | + this.type = type; |
| 33 | + this.name = name; |
| 34 | + this.imgPath = imgPath; |
| 35 | + this.sessionId = sessionId; |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public String getType() { |
| 40 | + return type; |
| 41 | + } |
| 42 | + |
| 43 | + public String getName() { |
| 44 | + return name; |
| 45 | + } |
| 46 | + |
| 47 | + public String getImgPath() { |
| 48 | + return imgPath; |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + protected JSONObject packData() { |
| 53 | + JSONObject object = new JSONObject(); |
| 54 | + object.put(MessageConstant.Card.type, type); |
| 55 | + object.put(MessageConstant.Card.name, name); |
| 56 | + object.put(MessageConstant.Card.imgPath, imgPath); |
| 57 | + object.put(MessageConstant.Card.sessionId, sessionId); |
| 58 | + return object; |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + public WritableMap toReactNative() { |
| 63 | + WritableMap writableMap = Arguments.createMap(); |
| 64 | + writableMap.putString(MessageConstant.Card.type, type); |
| 65 | + writableMap.putString(MessageConstant.Card.name, name); |
| 66 | + writableMap.putString(MessageConstant.Card.imgPath, imgPath); |
| 67 | + writableMap.putString(MessageConstant.Card.sessionId, sessionId); |
| 68 | + return writableMap; |
| 69 | + } |
| 70 | +} |
0 commit comments