Search in sources :

Example 66 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.

the class MessageRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray data = result[0];
    JSONArray profiles = result[1];
    JSONArray urls = result[2];
    assocData(data, profiles, "author_id", "id", "author_name", "name");
    assocData(data, urls, "author_id", "id", "author_pic", "url");
    MessageDeserializer deserializer = new MessageDeserializer();
    ArrayList<GraphObject> messages = (ArrayList<GraphObject>) deserializer.deserializeArray(data);
    Collections.reverse(messages);
    setHasMoreData(messages.size() >= 20);
    return messages;
}
Also used : MessageDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.MessageDeserializer) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 67 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.

the class NewsFeedRequest method handleResult.

@Override
public List<GraphObject> handleResult(JSONArray[] result) {
    JSONArray data = result[0];
    JSONArray data2 = result[1];
    JSONArray links = result[2];
    JSONArray photos = result[3];
    JSONArray videos = result[4];
    JSONArray status = result[5];
    JSONArray events = result[6];
    JSONArray profiles = result[7];
    JSONArray pages = result[8];
    JSONArray pics = result[9];
    JSONArray places = result[10];
    JSONArray apps = result[11];
    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(data, profiles, "actor_id", "id", "actor_name", "name", "actor_type", "type");
    assocData2(data, profiles, "target_id", "id", "target_name", "name", "target_type", "type");
    assocData(data, pics, "actor_id", "id", "actor_pic", "url");
    assocData2(data2, profiles, "actor_id", "id", "actor_name", "name", "actor_type", "type");
    assocData2(data2, profiles, "target_id", "id", "target_name", "name", "target_type", "type");
    assocData(data2, pics, "actor_id", "id", "actor_pic", "url");
    assocData(data, places, "place", "page_id", "place_name", "name");
    assocData3(data, profiles, "tagged_ids", "id", "tagged_tags");
    assocData3(data2, profiles, "tagged_ids", "id", "tagged_tags");
    assocStreamToEvent(data, events);
    assocStreamToLikedPages(data, pages);
    assocStreamToObjectBySubPostId(data, links, "link_id", "link");
    assocStreamToObjectBySubPostId(data, photos, "object_id", "photo");
    assocStreamToObjectBySubPostId(data, videos, "vid", "video");
    assocStreamToStatus(data, status);
    assocStreamToObjectById(data, apps, "app_id", "app_id", "application");
    assocStreamToObjectById(data, data2, "parent_post_id", "post_id", "parent_stream");
    StreamDeserializer deserializer = new StreamDeserializer();
    ArrayList<GraphObject> streams = (ArrayList<GraphObject>) deserializer.deserializeArray(data);
    if (mustReverse())
        Collections.reverse(streams);
    setHasMoreData(streams.size() > 0);
    return streams;
}
Also used : StreamDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.StreamDeserializer) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 68 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.

the class NotificationRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray notifications = result[0];
    JSONArray friendRequests = result[1];
    JSONArray urls = result[2];
    JSONArray names = result[3];
    JSONArray groups = result[4];
    assocData(notifications, urls, "sender_id", "id", "sender_pic", "url");
    assocData(notifications, names, "sender_id", "id", "sender_name", "name");
    assocStreamToObjectById(notifications, groups, "object_id", "gid", "group");
    for (int i = 0; i < urls.length(); i++) {
        JSONObject jsonObject = urls.optJSONObject(i);
        try {
            jsonObject.putOpt("id", String.valueOf(jsonObject.opt("id")));
        } catch (JSONException e) {
        // e.printStackTrace();
        }
    }
    for (int i = 0; i < names.length(); i++) {
        JSONObject jsonObject = names.optJSONObject(i);
        try {
            jsonObject.putOpt("id", String.valueOf(jsonObject.opt("id")));
        } catch (JSONException e) {
        // e.printStackTrace();
        }
    }
    assocData(notifications, names, "object_id", "id", "object_name", "name");
    assocData(friendRequests, urls, "uid_from", "id", "uid_from_pic", "url");
    assocData(friendRequests, names, "uid_from", "id", "uid_from_name", "name");
    NotificationDeserializer nDeserializer = new NotificationDeserializer();
    ArrayList<GraphObject> n = (ArrayList<GraphObject>) nDeserializer.deserializeArray(notifications);
    FriendRequestDeserializer fDeserializer = new FriendRequestDeserializer();
    ArrayList<GraphObject> f = (ArrayList<GraphObject>) fDeserializer.deserializeArray(friendRequests);
    ArrayList<GraphObject> list = new ArrayList<GraphObject>();
    list.addAll(n);
    list.addAll(f);
    setHasMoreData(false);
    return list;
}
Also used : JSONObject(org.json.JSONObject) FriendRequestDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.FriendRequestDeserializer) NotificationDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.NotificationDeserializer) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 69 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.

the class NotificationRequest2 method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray notifications = result[0];
    JSONArray friendRequests = result[1];
    JSONArray urls = result[2];
    JSONArray names = result[3];
    JSONArray friends = result[4];
    JSONArray events = result[5];
    JSONArray pages = result[6];
    JSONArray groups = result[7];
    JSONArray comments = result[8];
    assocData(notifications, urls, "sender_id", "id", "sender_pic", "url");
    assocData(notifications, names, "sender_id", "id", "sender_name", "name");
    assocStreamToObjectById(notifications, friends, "object_id", "uid", "friend");
    assocStreamToObjectById(notifications, events, "object_id", "eid", "event");
    assocStreamToObjectById(notifications, pages, "object_id", "page_id", "page");
    assocStreamToObjectById(notifications, groups, "object_id", "gid", "group");
    assocStreamToObjectById(notifications, comments, "object_id", "object_id", "comment");
    for (int i = 0; i < urls.length(); i++) {
        JSONObject jsonObject = urls.optJSONObject(i);
        try {
            jsonObject.putOpt("id", String.valueOf(jsonObject.opt("id")));
        } catch (JSONException e) {
        // e.printStackTrace();
        }
    }
    for (int i = 0; i < names.length(); i++) {
        JSONObject jsonObject = names.optJSONObject(i);
        try {
            jsonObject.putOpt("id", String.valueOf(jsonObject.opt("id")));
        } catch (JSONException e) {
        // e.printStackTrace();
        }
    }
    assocData(friendRequests, urls, "uid_from", "id", "uid_from_pic", "url");
    assocData(friendRequests, names, "uid_from", "id", "uid_from_name", "name");
    NotificationDeserializer nDeserializer = new NotificationDeserializer();
    ArrayList<GraphObject> n = (ArrayList<GraphObject>) nDeserializer.deserializeArray(notifications);
    FriendRequestDeserializer fDeserializer = new FriendRequestDeserializer();
    ArrayList<GraphObject> f = (ArrayList<GraphObject>) fDeserializer.deserializeArray(friendRequests);
    ArrayList<GraphObject> list = new ArrayList<GraphObject>();
    list.addAll(n);
    list.addAll(f);
    setHasMoreData(false);
    return list;
}
Also used : JSONObject(org.json.JSONObject) FriendRequestDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.FriendRequestDeserializer) NotificationDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.NotificationDeserializer) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 70 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.

the class PageProfileRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray pageData = result[0];
    JSONArray urls = result[1];
    assocData(pageData, urls, "page_id", "id", "pic", "url");
    JSONObject page = pageData.optJSONObject(0);
    ArrayList<GraphObject> data = null;
    if (page != null) {
        PageDeserializer deserializer = new PageDeserializer();
        data = (ArrayList<GraphObject>) deserializer.deserializeArray(pageData);
    } else {
        data = new ArrayList<GraphObject>();
    }
    setHasMoreData(false);
    return data;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) PageDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.PageDeserializer)

Aggregations

GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)101 ArrayList (java.util.ArrayList)71 JSONArray (org.json.JSONArray)41 JSONObject (org.json.JSONObject)16 FriendDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.FriendDeserializer)11 PhotoDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.PhotoDeserializer)9 MultiObjectAdapter (com.abewy.android.apps.klyph.adapter.MultiObjectAdapter)7 Stream (com.abewy.android.apps.klyph.core.fql.Stream)7 View (android.view.View)6 KlyphNotification (com.abewy.android.apps.klyph.KlyphNotification)6 Notification (com.abewy.android.apps.klyph.core.fql.Notification)6 Photo (com.abewy.android.apps.klyph.core.fql.Photo)6 JSONException (org.json.JSONException)6 StreamDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.StreamDeserializer)5 Intent (android.content.Intent)4 ListView (android.widget.ListView)4 Event (com.abewy.android.apps.klyph.core.fql.Event)4 AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)4 TextButtonItem (com.abewy.klyph.items.TextButtonItem)4 AbsListView (android.widget.AbsListView)3