Search in sources :

Example 76 with GraphObject

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

the class StreamGroupRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONObject result) {
    Stream s = new Stream();
    s.setPost_id(result.optString("id"));
    ArrayList<GraphObject> list = new ArrayList<GraphObject>();
    list.add(s);
    return list;
}
Also used : ArrayList(java.util.ArrayList) Stream(com.abewy.android.apps.klyph.core.fql.Stream) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 77 with GraphObject

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

the class StreamRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray sData = result[0];
    JSONArray sData2 = 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(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(sData, apps, "app_id", "app_id", "application");
    assocStreamToObjectById(sData, sData2, "parent_post_id", "post_id", "parent_stream");
    StreamDeserializer sDeserializer = new StreamDeserializer();
    List<GraphObject> streams = sDeserializer.deserializeArray(sData);
    ArrayList<GraphObject> list = new ArrayList<GraphObject>();
    if (streams.size() > 0)
        list.add(streams.get(0));
    setHasMoreData(false);
    return list;
}
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 78 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject 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;
}
Also used : StreamDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.StreamDeserializer) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) CommentDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.CommentDeserializer) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 79 with GraphObject

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

the class PhotoRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray photo = result[0];
    JSONArray profiles = result[1];
    JSONArray album = result[2];
    JSONArray pics = result[3];
    JSONArray places = result[4];
    assocData2(photo, profiles, "owner", "id", "owner_name", "name", "owner_type", "type");
    assocData2(photo, profiles, "owner", "id", "target_name", "name", "target_type", "type");
    assocData(photo, album, "album_object_id", "object_id", "album_name", "name");
    assocData(photo, pics, "owner", "id", "owner_pic", "url");
    assocData(photo, places, "place", "page_id", "place_name", "name");
    PhotoDeserializer deserializer = new PhotoDeserializer();
    ArrayList<GraphObject> list = (ArrayList<GraphObject>) deserializer.deserializeArray(photo);
    setHasMoreData(false);
    return list;
}
Also used : JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) PhotoDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.PhotoDeserializer) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 80 with GraphObject

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

the class SearchEventRequest method handleResult.

@Override
public List<GraphObject> handleResult(JSONArray result) {
    List<GraphObject> list = new ArrayList<GraphObject>();
    int n = result.length();
    for (int i = 0; i < n; i++) {
        Event event = new Event();
        JSONObject json = result.optJSONObject(i);
        event.setEid(json.optString("id"));
        event.setName(json.optString("name"));
        event.setStart_time(json.optString("start_time"));
        event.setLocation(json.optString("location"));
        JSONObject pic = json.optJSONObject("picture");
        JSONObject data = pic.optJSONObject("data");
        event.setPic(data.optString("url"));
        list.add(event);
    }
    setHasMoreData(false);
    return list;
}
Also used : JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) Event(com.abewy.android.apps.klyph.core.fql.Event) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

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