use of com.abewy.android.apps.klyph.core.fql.serializer.StreamDeserializer in project Klyph by jonathangerbaud.
the class StreamRequest2 method handleResult.
@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
JSONArray data = result[0];
JSONArray data2 = result[1];
JSONArray data_ids = result[2];
JSONArray urls = result[3];
Log.d("StreamRequest", "Comments size " + data.length());
Log.d("StreamRequest", "subComments size " + data2.length());
assocData2(data, data_ids, "fromid", "id", "from_name", "name", "from_type", "type");
assocData(data, urls, "fromid", "id", "from_pic", "url");
assocData2(data2, data_ids, "fromid", "id", "from_name", "name", "from_type", "type");
assocData(data2, urls, "fromid", "id", "from_pic", "url");
JSONArray finalData = new JSONArray();
for (int i = 0; i < data.length(); i++) {
JSONObject topObject = data.optJSONObject(i);
final String topId = topObject.optString("id");
finalData.put(topObject);
for (int j = 0; j < data2.length(); j++) {
JSONObject subObject = data2.optJSONObject(j);
final String parentId = subObject.optString("parent_id");
if (topId.equals(parentId)) {
finalData.put(subObject);
}
}
}
CommentDeserializer cDeserializer = new CommentDeserializer();
ArrayList<GraphObject> comments = (ArrayList<GraphObject>) cDeserializer.deserializeArray(finalData);
if (result.length > 4) {
JSONArray sData = result[4];
JSONArray sData2 = result[5];
JSONArray links = result[6];
JSONArray photos = result[7];
JSONArray videos = result[8];
JSONArray status = result[9];
JSONArray events = result[10];
JSONArray profiles = result[11];
JSONArray pages = result[12];
JSONArray pics = result[13];
JSONArray places = result[14];
JSONArray apps = result[15];
assocData2(links, profiles, "owner", "id", "owner_name", "name", "owner_type", "type");
assocData2(links, profiles, "via_id", "id", "via_name", "name", "via_type", "type");
assocData(links, pics, "owner", "id", "owner_pic", "url");
assocData2(photos, profiles, "owner", "id", "owner_name", "name", "owner_type", "type");
assocData2(photos, profiles, "target", "id", "target_name", "name", "target_type", "type");
assocData(photos, pics, "owner", "id", "owner_pic", "url");
assocData(photos, places, "place", "page_id", "place_name", "name");
assocData2(videos, profiles, "owner", "id", "owner_name", "name", "owner_type", "type");
assocData(videos, pics, "owner", "id", "owner_pic", "url");
assocData2(status, profiles, "uid", "id", "uid_name", "name", "uid_type", "type");
assocData(status, pics, "uid", "id", "uid_pic", "url");
assocData(status, places, "place_id", "page_id", "place_name", "name");
assocData(pages, pics, "page_id", "id", "pic", "url");
assocData2(sData, profiles, "actor_id", "id", "actor_name", "name", "actor_type", "type");
assocData2(sData, profiles, "target_id", "id", "target_name", "name", "target_type", "type");
assocData2(sData2, profiles, "actor_id", "id", "actor_name", "name", "actor_type", "type");
assocData2(sData2, profiles, "target_id", "id", "target_name", "name", "target_type", "type");
assocData(sData, pics, "actor_id", "id", "actor_pic", "url");
assocData(sData, places, "place", "page_id", "place_name", "name");
assocData3(sData, profiles, "tagged_ids", "id", "tagged_tags");
assocData(sData2, pics, "actor_id", "id", "actor_pic", "url");
assocData(sData2, places, "place", "page_id", "place_name", "name");
assocData3(sData2, profiles, "tagged_ids", "id", "tagged_tags");
assocStreamToEvent(sData, events);
assocStreamToLikedPages(sData, pages);
assocStreamToObjectBySubPostId(sData, links, "link_id", "link");
assocStreamToObjectBySubPostId(sData, photos, "object_id", "photo");
assocStreamToObjectBySubPostId(sData, videos, "vid", "video");
assocStreamToStatus(sData, status);
assocStreamToObjectById(data, apps, "app_id", "app_id", "application");
assocStreamToObjectById(data, apps, "parent_post_id", "post_id", "parent_stream");
StreamDeserializer sDeserializer = new StreamDeserializer();
List<GraphObject> streams = sDeserializer.deserializeArray(sData);
if (streams.size() > 0) {
comments.add(0, streams.get(0));
}
}
setHasMoreData(comments.size() >= 0);
return comments;
}
Aggregations