NIMSDK-AOS  10.8.10
SystemMessage.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.msg.model;
2 
3 import android.text.TextUtils;
4 
5 import com.netease.nimlib.log.NimLog;
8 
9 import org.json.JSONException;
10 import org.json.JSONObject;
11 
12 import java.io.Serializable;
13 
14 /**
15  * 系统通知数据结构
16  */
17 public class SystemMessage implements Serializable {
18 
19  private static final String TAG = "SystemMessage";
20 
21  // 系统通知的服务器ID
22  private String messageServerId;
23 
24  private long messageId;
25 
26  private SystemMessageType type;
27 
28  private String fromAccount;
29 
30  private String targetId;
31 
32  private long time;
33 
34  private SystemMessageStatus status;
35 
36  private String content;
37 
38  private String attach;
39 
40  private Object attachObject;
41 
42  private boolean unread;
43 
44  private String customInfo;
45 
46  /**
47  * 获取系统通知ID
48  *
49  * @return 消息ID
50  */
51  public long getMessageId() {
52  return messageId;
53  }
54 
55  /**
56  * 设置系统通知ID
57  *
58  * @param messageId 消息ID
59  */
60  public void setMessageId(long messageId) {
61  this.messageId = messageId;
62  }
63 
64  public String getMessageServerId() {
65  return messageServerId;
66  }
67 
68  public void setMessageServerId(String messageServerId) {
69  this.messageServerId = messageServerId;
70  }
71 
72  /**
73  * 获取系统通知类型
74  *
75  * @return 系统通知类型
76  */
78  return type;
79  }
80 
81  /**
82  * 设置系统通知类型
83  *
84  * @param type 类型
85  */
86  public void setType(int type) {
87  this.type = SystemMessageType.typeOfValue(type);
88  }
89 
90  /**
91  * 该系统通知的发起方帐号。<br>
92  * 例如:申请加入群的申请者,同意入群邀请的同意者
93  *
94  * @return 发起方帐号
95  */
96  public String getFromAccount() {
97  return fromAccount;
98  }
99 
100  /**
101  * 设置发起方帐号
102  *
103  * @param fromAccount 发起方帐号
104  */
105  public void setFromAccount(String fromAccount) {
106  this.fromAccount = fromAccount;
107  }
108 
109  /**
110  * 获取系统通知的目标ID.<br>
111  * 例如:申请入群,被拒绝申请的群ID,
112  *
113  * @return 目标ID
114  */
115  public String getTargetId() {
116  return targetId;
117  }
118 
119  /**
120  * 设置系统通知的目标ID
121  *
122  * @param targetId 目标ID
123  */
124  public void setTargetId(String targetId) {
125  this.targetId = targetId;
126  }
127 
128  /**
129  * 获取系统通知的发出时间,单位为ms
130  *
131  * @return 发出时间
132  */
133  public long getTime() {
134  return time;
135  }
136 
137  /**
138  * 设置系统通知的发出时间
139  *
140  * @param time 发出时间
141  */
142  public void setTime(long time) {
143  this.time = time;
144  }
145 
146  /**
147  * 获取系统通知的处理状态
148  *
149  * @return 状态
150  */
152  return status;
153  }
154 
155  /**
156  * 设置系统通知的处理状态
157  *
158  * @param status 状态
159  */
160  public void setStatus(SystemMessageStatus status) {
161  this.status = status;
162  }
163 
164  /**
165  * 获取系统通知的内容。 <br>
166  * 例如:申请附言,拒绝理由
167  *
168  * @return 内容
169  */
170  public String getContent() {
171  return content;
172  }
173 
174  /**
175  * 设置系统通知的内容
176  *
177  * @param content 内容
178  */
179  public void setContent(String content) {
180  this.content = content;
181  }
182 
183  /**
184  * 获取系统通知的附件内容。<br>
185  * 该字段用于日后扩展
186  *
187  * @return 附件
188  */
189  public String getAttach() {
190  return attach;
191  }
192 
193  /**
194  * 设置系统通知的附件内容。
195  *
196  * @param attach 附件
197  */
198  public void setAttach(String attach) {
199  if (!TextUtils.isEmpty(attach)) {
200  try {
201  JSONObject object = new JSONObject(attach);
202  customInfo = object.optString("attach");
203  } catch (JSONException e) {
204  e.printStackTrace();
205  NimLog.e(TAG, "get custom info err , attach = " + attach, e);
206  }
207  }
208  this.attach = attach;
209  }
210 
211  /**
212  * 获取系统通知附件内容解析后的对象。<br>
213  * 对于第三方app自定义消息类型,该域可自行解析。<br>
214  * 对于内置的系统通知类型,该域的返回值定义见{@link com.netease.nimlib.sdk.msg.constant.SystemMessageType}
215  *
216  * @return 附件对象
217  */
218  public Object getAttachObject() {
219  return attachObject;
220  }
221 
222  /**
223  * 设置解析后的附件对象。<br>
224  * 该字段和attach是独立的,以便第三方app缓存自己的附件对象。
225  *
226  * @param object 附件对象
227  */
228  public void setAttachObject(Object object) {
229  this.attachObject = object;
230  }
231 
232  /**
233  * 判断该系统通知是否已读
234  *
235  * @return true表示未读,false表示已读
236  */
237  public boolean isUnread() {
238  return unread;
239  }
240 
241  /**
242  * 设置改系统通知已读/未读
243  *
244  * @param unread true表示未读,false表示已读
245  */
246  public void setUnread(boolean unread) {
247  this.unread = unread;
248  }
249 
250 
251  /**
252  * 获取自定义信息,目前只有拉人入群时可以设置
253  *
254  * @return customInfo
255  */
256  public String getCustomInfo() {
257 
258  return customInfo;
259  }
260 }
Object getAttachObject()
获取系统通知附件内容解析后的对象。 对于第三方app自定义消息类型,该域可自行解析。 对于内置的系统通知...
void setMessageServerId(String messageServerId)
String getCustomInfo()
获取自定义信息,目前只有拉人入群时可以设置
SystemMessageStatus getStatus()
获取系统通知的处理状态
void setAttachObject(Object object)
设置解析后的附件对象。 该字段和attach是独立的,以便第三方app缓存自己的附件对象。 ...
SystemMessageType getType()
获取系统通知类型
boolean isUnread()
判断该系统通知是否已读
void setMessageId(long messageId)
设置系统通知ID
void setUnread(boolean unread)
设置改系统通知已读/未读
void setType(int type)
设置系统通知类型
void setTime(long time)
设置系统通知的发出时间
void setTargetId(String targetId)
设置系统通知的目标ID
void setStatus(SystemMessageStatus status)
设置系统通知的处理状态
String getFromAccount()
该系统通知的发起方帐号。 例如:申请加入群的申请者,同意入群邀请的同意者
void setContent(String content)
设置系统通知的内容
void setAttach(String attach)
设置系统通知的附件内容。
String getTargetId()
获取系统通知的目标ID.
void setFromAccount(String fromAccount)
设置发起方帐号
String getAttach()
获取系统通知的附件内容。 该字段用于日后扩展
String getContent()
获取系统通知的内容。 例如:申请附言,拒绝理由
long getTime()
获取系统通知的发出时间,单位为ms