Search in sources :

Example 1 with GraphObject

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

the class UserActivity method getCachedDataFromInstanceState.

@Override
protected List<GraphObject> getCachedDataFromInstanceState(Bundle savedInstanceState) {
    User user = savedInstanceState.getParcelable(USER);
    hasReceivedFriendRequest = savedInstanceState.getBoolean(HAS_RECEIVED_FRIEND_REQUEST);
    hasSentFriendRequest = savedInstanceState.getBoolean(HAS_SENT_FRIEND_REQUEST);
    List<GraphObject> data = new ArrayList<GraphObject>();
    data.add(user);
    return data;
}
Also used : User(com.abewy.android.apps.klyph.core.fql.User) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 2 with GraphObject

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

the class AlbumTaggedPhotosRequest 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)

Example 3 with GraphObject

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

the class AlbumVideosRequest method handleResult.

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

Example 4 with GraphObject

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

the class PageActivity method getCachedDataFromInstanceState.

@Override
protected List<GraphObject> getCachedDataFromInstanceState(Bundle savedInstanceState) {
    Page page = savedInstanceState.getParcelable("page");
    List<GraphObject> data = new ArrayList<GraphObject>();
    data.add(page);
    return data;
}
Also used : ArrayList(java.util.ArrayList) Page(com.abewy.android.apps.klyph.core.fql.Page) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 5 with GraphObject

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

the class ElementAlbumRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray data = result[0];
    JSONArray photos = result[1];
    assocData(data, photos, "cover_pid", "pid", "cover_images", "images");
    int n = 25;
    Album taggedAlbum = null;
    Album videoAlbum = null;
    if (result.length == 6) {
        JSONArray tagged = result[2];
        JSONArray user = result[3];
        JSONArray profile = result[4];
        PhotoDeserializer pd = new PhotoDeserializer();
        List<GraphObject> taggedPhotos = pd.deserializeArray(tagged);
        int nt = taggedPhotos.size();
        if (nt > 0) {
            taggedAlbum = new Album();
            taggedAlbum.setOwner(id);
            taggedAlbum.setPhoto_count(nt);
            taggedAlbum.setVideo_count(0);
            taggedAlbum.setIsTaggedAlbum(true);
            taggedAlbum.setIs_video_album(false);
            String eName = "";
            if (user.length() > 0) {
                UserDeserializer ud = new UserDeserializer();
                User u = (User) ud.deserializeArray(user).get(0);
                eName = u.getFirst_name().length() > 0 ? u.getFirst_name() : u.getName();
            } else if (profile.length() > 0) {
                ProfileDeserializer prd = new ProfileDeserializer();
                Profile p = (Profile) prd.deserializeArray(profile).get(0);
                eName = p.getName();
            }
            taggedAlbum.setName(KlyphApplication.getInstance().getString(R.string.tagged_photos_of, eName));
            Photo photo = (Photo) taggedPhotos.get(0);
            taggedAlbum.setCover_pid(photo.getPid());
            taggedAlbum.setCover_images(photo.getImages());
        }
        JSONArray videos = result[5];
        if (videos.length() > 0) {
            videoAlbum = new Album();
            videoAlbum.setOwner(id);
            videoAlbum.setPhoto_count(nt);
            videoAlbum.setVideo_count(0);
            videoAlbum.setIsTaggedAlbum(false);
            videoAlbum.setIs_video_album(true);
            for (int i = 0; i < videos.length(); i++) {
                JSONObject v = videos.optJSONObject(i);
                if (v != null && v.optString("thumbnail_link") != null) {
                    Image cover = new Photo.Image();
                    cover.setSource(v.optString("thumbnail_link"));
                    List<Image> images = new ArrayList<Photo.Image>();
                    images.add(cover);
                    videoAlbum.setOwner(v.optString("owner"));
                    videoAlbum.setCover_images(images);
                    break;
                }
            }
        }
    }
    AlbumDeserializer deserializer = new AlbumDeserializer();
    ArrayList<GraphObject> albums = (ArrayList<GraphObject>) deserializer.deserializeArray(data);
    if (videoAlbum != null)
        albums.add(0, videoAlbum);
    if (taggedAlbum != null)
        albums.add(0, taggedAlbum);
    setHasMoreData(albums.size() >= n);
    return albums;
}
Also used : UserDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.UserDeserializer) User(com.abewy.android.apps.klyph.core.fql.User) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) Album(com.abewy.android.apps.klyph.core.fql.Album) PhotoDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.PhotoDeserializer) Photo(com.abewy.android.apps.klyph.core.fql.Photo) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) Image(com.abewy.android.apps.klyph.core.fql.Photo.Image) Profile(com.abewy.android.apps.klyph.core.fql.Profile) JSONObject(org.json.JSONObject) AlbumDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.AlbumDeserializer) ProfileDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.ProfileDeserializer)

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