use of com.abewy.android.apps.klyph.core.graph.serializer.CommentDeserializer in project Klyph by jonathangerbaud.
the class CommentsRequest method handleResult.
@Override
public ArrayList<GraphObject> handleResult(JSONArray result) {
JSONArray jsonArray = new JSONArray();
int n = result.length();
for (int i = 0; i < n; i++) {
JSONObject comment = result.optJSONObject(i);
if (comment != null) {
JSONObject parent = comment.optJSONObject("parent");
// If this is a reply, then we skip it
if (parent != null) {
continue;
}
jsonArray.put(comment);
JSONObject subComments = comment.optJSONObject("comments");
if (subComments != null) {
JSONArray data = subComments.optJSONArray("data");
if (data != null) {
int m = data.length();
for (int j = 0; j < m; j++) {
JSONObject subComment = data.optJSONObject(j);
if (subComment != null) {
jsonArray.put(subComment);
}
}
}
}
}
}
CommentDeserializer deserializer = new CommentDeserializer();
ArrayList<GraphObject> comments = (ArrayList<GraphObject>) deserializer.deserializeArray(jsonArray);
setHasMoreData(comments.size() > 0);
return comments;
}
Aggregations