Search in sources :

Example 1 with ProfilePicDeserializer

use of com.abewy.android.apps.klyph.core.fql.serializer.ProfilePicDeserializer in project Klyph by jonathangerbaud.

the class UserProfilePhotoRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    PhotoDeserializer deserializer = new PhotoDeserializer();
    ArrayList<GraphObject> photos = (ArrayList<GraphObject>) deserializer.deserializeArray(result[0]);
    Log.d("UserProfileRequest", "photos " + photos.size());
    ProfilePicDeserializer ppDeserializer = new ProfilePicDeserializer();
    ArrayList<GraphObject> pictures = (ArrayList<GraphObject>) ppDeserializer.deserializeArray(result[1]);
    Log.d("UserProfileRequest", "pictures " + pictures.size());
    ArrayList<GraphObject> selectedPhoto = new ArrayList<GraphObject>();
    if (pictures.size() > 0) {
        ProfilePic pic = (ProfilePic) pictures.get(0);
        String url = pic.getUrl();
        url = url.substring(url.indexOf("_") + 1);
        url = url.substring(0, url.lastIndexOf("_"));
        for (GraphObject graphObject : photos) {
            Photo photo = (Photo) graphObject;
            for (Image image : photo.getImages()) {
                String imageUrl = image.getSource();
                imageUrl = imageUrl.substring(imageUrl.indexOf("_") + 1);
                imageUrl = imageUrl.substring(0, imageUrl.lastIndexOf("_"));
                Log.d("UserProfileRequest", url + " " + imageUrl);
                if (url.equals(imageUrl)) {
                    selectedPhoto.add(photo);
                    Log.d("UserProfileRequest", "id " + photo.getObject_id());
                    setHasMoreData(false);
                    return selectedPhoto;
                }
            }
        }
    }
    setHasMoreData(false);
    return selectedPhoto;
}
Also used : ArrayList(java.util.ArrayList) ProfilePicDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.ProfilePicDeserializer) ProfilePic(com.abewy.android.apps.klyph.core.fql.ProfilePic) 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)

Aggregations

Photo (com.abewy.android.apps.klyph.core.fql.Photo)1 Image (com.abewy.android.apps.klyph.core.fql.Photo.Image)1 ProfilePic (com.abewy.android.apps.klyph.core.fql.ProfilePic)1 PhotoDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.PhotoDeserializer)1 ProfilePicDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.ProfilePicDeserializer)1 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)1 ArrayList (java.util.ArrayList)1