Skip to content

Commit 77c3b23

Browse files
KenChoiKenChoi
authored andcommitted
fix bug
1 parent 99bba48 commit 77c3b23

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

android/src/io/jchat/android/utils/ResultUtils.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,19 @@ public void gotResult(int status, String desc, UserInfo userInfo) {
274274

275275
public static WritableArray toJSArray(List list) {
276276
WritableArray array = Arguments.createArray();
277-
278-
for (Object object : list) {
279-
if (object instanceof UserInfo) {
280-
array.pushMap(toJSObject((UserInfo) object));
281-
} else if (object instanceof GroupInfo) {
282-
array.pushMap(toJSObject((GroupInfo) object));
283-
} else if (object instanceof Message) {
284-
array.pushMap(toJSObject((Message) object));
285-
} else if (object instanceof Conversation) {
286-
array.pushMap(toJSObject((Conversation) object));
287-
} else {
288-
array.pushString(object.toString());
277+
if (list != null) {
278+
for (Object object : list) {
279+
if (object instanceof UserInfo) {
280+
array.pushMap(toJSObject((UserInfo) object));
281+
} else if (object instanceof GroupInfo) {
282+
array.pushMap(toJSObject((GroupInfo) object));
283+
} else if (object instanceof Message) {
284+
array.pushMap(toJSObject((Message) object));
285+
} else if (object instanceof Conversation) {
286+
array.pushMap(toJSObject((Conversation) object));
287+
} else {
288+
array.pushString(object.toString());
289+
}
289290
}
290291
}
291292

@@ -294,8 +295,10 @@ public static WritableArray toJSArray(List list) {
294295

295296
public static WritableArray toJSArray(List<ChatRoomInfo> list, Callback fail) {
296297
WritableArray array = Arguments.createArray();
297-
for (ChatRoomInfo chatRoomInfo : list) {
298-
array.pushMap(toJSObject(chatRoomInfo, fail));
298+
if (null != list) {
299+
for (ChatRoomInfo chatRoomInfo : list) {
300+
array.pushMap(toJSObject(chatRoomInfo, fail));
301+
}
299302
}
300303
return array;
301304
}

0 commit comments

Comments
 (0)