use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class AlbumPhotosAllRequest method handleResult.
@Override
public ArrayList<GraphObject> handleResult(JSONArray result) {
PhotoDeserializer deserializer = new PhotoDeserializer();
ArrayList<GraphObject> photos = (ArrayList<GraphObject>) deserializer.deserializeArray(result);
setHasMoreData(false);
return photos;
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class AlbumPhotosRequest 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;
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class ConversationFragment method onListItemClick.
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
GraphObject object = (GraphObject) getAdapter().getItem(position);
if (object instanceof Message) {
final Message message = (Message) object;
List<String> list = new ArrayList<String>();
int copyText = -1;
int downloadImage = -1;
String body = message.getBody();
if (body.length() > 0) {
list.add(getString(R.string.copy_text));
copyText = list.size() - 1;
Spannable spannable = new SpannableString(body);
Linkify.addLinks(spannable, Linkify.WEB_URLS);
URLSpan[] urls = spannable.getSpans(0, spannable.length(), URLSpan.class);
if (urls.length > 0) {
for (URLSpan urlSpan : urls) {
list.add(urlSpan.getURL());
}
}
}
/*
* if (message.getAttachment() != null)
* {
* list.add(getString(R.string.download_image));
* downloadImage = list.size() - 1;
* }
*/
final int fcopyText = copyText;
final int fdownloadImage = downloadImage;
final String[] items = list.toArray(new String[0]);
// For Api 8 to 10
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (which == fcopyText) {
handleCopyTextAction(message);
} else if (which == fdownloadImage) {
handleDownloadAction(message);
} else {
handleUrlAction(items[which]);
}
}
});
builder.create().show();
}
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject 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;
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject 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