Search in sources :

Example 11 with GraphObject

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

the class FollowedPeopleRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray data = result[0];
    JSONArray urls = result[1];
    assocData(data, urls, "uid", "id", "pic", "url");
    FriendDeserializer deserializer = new FriendDeserializer();
    ArrayList<GraphObject> friends = (ArrayList<GraphObject>) deserializer.deserializeArray(data);
    setHasMoreData(friends.size() >= 50);
    return friends;
}
Also used : JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) FriendDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.FriendDeserializer)

Example 12 with GraphObject

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

the class EventRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray eventData = result[0];
    JSONArray rsvp_status = result[1];
    ArrayList<GraphObject> data = new ArrayList<GraphObject>();
    EventDeserializer deserializer = new EventDeserializer();
    Event event = (Event) deserializer.deserializeArray(eventData).get(0);
    try {
        JSONObject o = rsvp_status.getJSONObject(0);
        event.setUserResponse(o.getString("rsvp_status"));
    } catch (JSONException e) {
        event.setUserResponse(EventResponse.NOT_REPLIED.toString());
    }
    data.add(event);
    setHasMoreData(false);
    return data;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) Event(com.abewy.android.apps.klyph.core.fql.Event) JSONException(org.json.JSONException) EventDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.EventDeserializer) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 13 with GraphObject

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

the class FriendListsRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray result) {
    FriendListDeserializer deserializer = new FriendListDeserializer();
    ArrayList<GraphObject> friendLists = (ArrayList<GraphObject>) deserializer.deserializeArray(result);
    setHasMoreData(false);
    return friendLists;
}
Also used : ArrayList(java.util.ArrayList) FriendListDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.FriendListDeserializer) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 14 with GraphObject

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

the class FriendsRequestNotificationRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray data = result[0];
    JSONArray urls = result[1];
    JSONArray names = result[2];
    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(data, urls, "uid_from", "id", "uid_from_pic", "url");
    assocData(data, names, "uid_from", "id", "uid_from_name", "name");
    FriendRequestDeserializer deserializer = new FriendRequestDeserializer();
    ArrayList<GraphObject> friendRequests = (ArrayList<GraphObject>) deserializer.deserializeArray(data);
    return friendRequests;
}
Also used : JSONObject(org.json.JSONObject) FriendRequestDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.FriendRequestDeserializer) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 15 with GraphObject

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

the class GroupPhotosRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray result) {
    PhotoDeserializer deserializer = new PhotoDeserializer();
    ArrayList<GraphObject> photos = (ArrayList<GraphObject>) deserializer.deserializeArray(result);
    setHasMoreData(photos.size() >= 50);
    return photos;
}
Also used : ArrayList(java.util.ArrayList) PhotoDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.PhotoDeserializer) 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