NIMSDK-AOS  9.16.0
ChatRoomQueueBatchAddAttachment.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.chatroom.model;
2 
3 import androidx.annotation.NonNull;
4 import androidx.annotation.Nullable;
5 
6 import com.netease.nimlib.log.NimLog;
8 import com.netease.nimlib.util.JSONHelper;
9 
10 import org.json.JSONArray;
11 import org.json.JSONException;
12 import org.json.JSONObject;
13 
14 import java.util.ArrayList;
15 import java.util.List;
16 import java.util.Map;
17 
19  private static final String TAG_QUEUE_CHANGE = "queueChange";
20  private static final String TAG_TYPE = "_e";
21  private static final String TAG_ELEMENTS = "elements";
22 
23  @Nullable
24  private ChatRoomQueueChangeType chatRoomQueueChangeType = null;
25  @Nullable
26  private List<Map<String, String>> contentMapList = null;
27 
33  @Override
34  public void parse(JSONObject json) {
35  super.parse(json);
36  if (json.has(TAG_QUEUE_CHANGE)) {
37  String queueChange = JSONHelper.getString(json, TAG_QUEUE_CHANGE);
38  JSONObject jsonObject = JSONHelper.parse(queueChange);
39  if (jsonObject == null) {
40  return;
41  }
42  if (jsonObject.has(TAG_TYPE)) {
43  chatRoomQueueChangeType = ChatRoomQueueChangeType.valueOf(JSONHelper.getString(jsonObject, TAG_TYPE));
44  }
45 
46  if (jsonObject.has(TAG_ELEMENTS)) {
47  String content = JSONHelper.getString(jsonObject, TAG_ELEMENTS);
48  JSONArray contentJsonArray = JSONHelper.parseArray(content);
49  if (contentJsonArray == null) {
50  return;
51  }
52  int length = contentJsonArray.length();
53  contentMapList = new ArrayList<>(length);
54  try {
55  for (int i = 0; i < length; ++i) {
56  contentMapList.add(JSONHelper.parseMapFromJsonObject(contentJsonArray.getJSONObject(i)));
57  }
58  } catch (JSONException e) {
59  NimLog.uiError("parse elements error", e);
60  }
61  }
62  }
63  }
64 
65  @Nullable
67  return chatRoomQueueChangeType;
68  }
69 
70  @Nullable
71  public List<Map<String, String>> getContentMapList() {
72  return contentMapList;
73  }
74 
75  @NonNull
76  @Override
77  public String toString() {
78  return "ChatRoomQueueBatchAddAttachment{" +
79  ", " + super.toString() +
80  "chatRoomQueueChangeType=" + chatRoomQueueChangeType +
81  ", contentMapList=" + contentMapList +
82  '}';
83  }
84 }