use of com.abewy.android.apps.klyph.core.fql.serializer.UserDeserializer 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;
}
use of com.abewy.android.apps.klyph.core.fql.serializer.UserDeserializer in project Klyph by jonathangerbaud.
the class UserRequest method handleResult.
@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
JSONArray userData = result[0];
JSONArray urls = result[1];
assocData(userData, urls, "uid", "id", "pic", "url");
JSONObject user = userData.optJSONObject(0);
ArrayList<GraphObject> data = null;
if (user != null) {
UserDeserializer deserializer = new UserDeserializer();
data = (ArrayList<GraphObject>) deserializer.deserializeArray(userData);
} else {
data = new ArrayList<GraphObject>();
}
setHasMoreData(false);
return data;
}
use of com.abewy.android.apps.klyph.core.fql.serializer.UserDeserializer in project Klyph by jonathangerbaud.
the class UserProfileRequest method handleResult.
@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
JSONArray userData = result[0];
JSONArray familyData = result[1];
JSONArray urls = result[2];
JSONArray isFriend = result[3];
JSONArray friendRequest = result[4];
assocData(userData, urls, "uid", "id", "pic", "url");
JSONObject user = userData.optJSONObject(0);
ArrayList<GraphObject> data = null;
if (user != null) {
try {
user.put("family", familyData);
} catch (JSONException e) {
}
if (isFriend != null && isFriend.length() == 1) {
try {
user.putOpt("isFriend", true);
} catch (JSONException e) {
e.printStackTrace();
}
}
UserDeserializer deserializer = new UserDeserializer();
data = (ArrayList<GraphObject>) deserializer.deserializeArray(userData);
FriendRequestDeserializer frDeserializer = new FriendRequestDeserializer();
List<GraphObject> fr = frDeserializer.deserializeArray(friendRequest);
if (fr.size() > 0) {
data.add(fr.get(0));
}
} else {
data = new ArrayList<GraphObject>();
}
setHasMoreData(false);
return data;
}
Aggregations