Search in sources :

Example 56 with GraphObject

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;
}
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 57 with GraphObject

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;
}
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 58 with GraphObject

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();
    }
}
Also used : AlertDialog(android.app.AlertDialog) Message(com.abewy.android.apps.klyph.core.fql.Message) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) URLSpan(android.text.style.URLSpan) SpannableString(android.text.SpannableString) Spannable(android.text.Spannable)

Example 59 with GraphObject

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;
}
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)

Example 60 with GraphObject

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;
}
Also used : UserDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.UserDeserializer) JSONObject(org.json.JSONObject) FriendRequestDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.FriendRequestDeserializer) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) 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