NIMSDK-AOS  9.19.0
QuickCommentOption.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.msg.model;
2 
3 import com.netease.nimlib.biz.constant.ITalkExtensionService;
4 import com.netease.nimlib.push.packet.marshal.Property;
5 import com.netease.nimlib.session.MsgHelper;
6 
7 import org.json.JSONObject;
8 
9 import java.io.Serializable;
10 import java.util.Map;
11 
12 /**
13  * 快速评论的信息
14  *
15  * @author chenjili
16  * @date 2020/4/01
17  * @see ITalkExtensionService.QuickCommentTag
18  */
19 public class QuickCommentOption implements Serializable {
20  private final String fromAccount;
21  private final long replyType;
22  private final long time;
23  private final String ext;
24  private final boolean needPush;
25  private final boolean needBadge;
26  private final String pushTitle;
27  private final String pushContent;
28  private final Map<String, Object> pushPayload;
29 
30  public static QuickCommentOption fromProperty(Property property) {
31  String fromAccount = property.get(ITalkExtensionService.QuickCommentTag.fromAccount);
32  long replyType = property.getLong(ITalkExtensionService.QuickCommentTag.replyType);
33  long time = property.getLong(ITalkExtensionService.QuickCommentTag.time);
34  String ext = property.get(ITalkExtensionService.QuickCommentTag.ext);
35  boolean needPush = property.getInteger(ITalkExtensionService.QuickCommentTag.needPush) == 1;
36  boolean needBadge = property.getInteger(ITalkExtensionService.QuickCommentTag.needBadge) == 1;
37  String pushTitle = property.get(ITalkExtensionService.QuickCommentTag.pushTitle);
38  String pushContent = property.get(ITalkExtensionService.QuickCommentTag.pushContent);
39  Map<String, Object> pushPayload = MsgHelper.getMapFromJsonString(property.get(ITalkExtensionService.QuickCommentTag.pushPayload));
40  return new QuickCommentOption(fromAccount, replyType, time, ext, needPush, needBadge, pushTitle, pushContent, pushPayload);
41  }
42 
43  public static QuickCommentOption fromJson(final JSONObject obj) {
44  String fromAccount = obj.optString(String.valueOf(ITalkExtensionService.QuickCommentTag.fromAccount));
45  long replyType = obj.optLong(String.valueOf(ITalkExtensionService.QuickCommentTag.replyType));
46  long time = obj.optLong(String.valueOf(ITalkExtensionService.QuickCommentTag.time));
47  String ext = obj.optString(String.valueOf(ITalkExtensionService.QuickCommentTag.ext));
48  boolean needPush = obj.optInt(String.valueOf(ITalkExtensionService.QuickCommentTag.needPush)) == 1;
49  boolean needBadge = obj.optInt(String.valueOf(ITalkExtensionService.QuickCommentTag.needBadge)) == 1;
50  String pushTitle = obj.optString(String.valueOf(ITalkExtensionService.QuickCommentTag.pushTitle));
51  String pushContent = obj.optString(String.valueOf(ITalkExtensionService.QuickCommentTag.pushContent));
52  Map<String, Object> pushPayload = MsgHelper.getMapFromJsonString(obj.optString(String.valueOf(ITalkExtensionService.QuickCommentTag.pushPayload)));
53  return new QuickCommentOption(fromAccount, replyType, time, ext, needPush, needBadge, pushTitle, pushContent, pushPayload);
54  }
55 
56  public QuickCommentOption(String fromAccount, long replyType, long time, String ext) {
57  this(fromAccount, replyType, time, ext, false, false, "", "", null);
58  }
59 
60  public QuickCommentOption(String fromAccount, long replyType, long time, String ext, boolean needPush,
61  boolean needBadge, String pushTitle, String pushContent, Map<String, Object> pushPayload) {
62  this.fromAccount = fromAccount;
63  this.replyType = replyType;
64  this.time = time;
65  this.ext = ext;
66  this.needPush = needPush;
67  this.needBadge = needBadge;
68  this.pushTitle = pushTitle;
69  this.pushContent = pushContent;
70  this.pushPayload = pushPayload;
71  }
72 
73  public String getFromAccount() {
74  return fromAccount;
75  }
76 
77  public long getReplyType() {
78  return replyType;
79  }
80 
81  public long getTime() {
82  return time;
83  }
84 
85  public String getExt() {
86  return ext;
87  }
88 
89  public boolean isNeedPush() {
90  return needPush;
91  }
92 
93  public boolean isNeedBadge() {
94  return needBadge;
95  }
96 
97  public String getPushTitle() {
98  return pushTitle;
99  }
100 
101  public String getPushContent() {
102  return pushContent;
103  }
104 
105  public Map<String, Object> getPushPayload() {
106  return pushPayload;
107  }
108 }
QuickCommentOption(String fromAccount, long replyType, long time, String ext)
QuickCommentOption(String fromAccount, long replyType, long time, String ext, boolean needPush, boolean needBadge, String pushTitle, String pushContent, Map< String, Object > pushPayload)
static QuickCommentOption fromProperty(Property property)
static QuickCommentOption fromJson(final JSONObject obj)