Search in sources :

Example 11 with Stream

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

the class StreamAdapter method manageAttachment.

private void manageAttachment(View view, StreamHolder holder, Stream stream) {
    Attachment attachment = stream.getAttachment();
    Media media = attachment.getMedia().size() > 0 ? attachment.getMedia().get(0) : null;
    int type = stream.getType();
    if ((type == 245 || type == 257) && stream.getParent_stream() != null) {
        final Stream parentStream = stream.getParent_stream();
        headerAdapter.mergeData(holder, parentStream, true);
        messageAdapter.mergeData(holder, parentStream);
        buttonBarAdapter.mergeData(holder, stream);
    }
    if (type == 161 && stream.getDescription_tags().size() > 0 && stream.getLiked_pages().size() > 0) {
        linkAdapter.manageLikedPage(holder, stream);
    }
    if (stream.isStatus()) {
        statusAdapter.mergeData(holder, stream);
    } else if (stream.isPhoto()) {
        photoAdapter.mergeData(holder, stream, stream.getPhoto());
    } else if (stream.isVideo()) {
        photoAdapter.mergeData(holder, stream, stream.getVideo());
    } else if (attachment.isPhoto() || ((media != null && media.isFydv()))) {
        photoAdapter.mergeData(holder, stream);
        buttonBarAdapter.mergeData(holder, stream);
    } else if (attachment.isAlbum()) {
        albumAdapter.mergeData(holder, stream);
        buttonBarAdapter.mergeData(holder, stream);
    } else if (attachment.isCheckin()) {
        manageAttachmentCheckin(view, holder, stream);
        buttonBarAdapter.mergeData(holder, stream);
    } else if (stream.getLink().isEventLink()) {
        linkAdapter.mergeData(holder, stream, stream.getLink());
    } else if (type == 161 || attachment.getMedia().size() > 0) {
        linkAdapter.mergeData(holder, stream);
        buttonBarAdapter.mergeData(holder, stream);
    } else if (stream.isLink()) {
        linkAdapter.mergeData(holder, stream, stream.getLink());
    } else {
        buttonBarAdapter.mergeData(holder, stream);
    }
}
Also used : Media(com.abewy.android.apps.klyph.core.fql.Media) Attachment(com.abewy.android.apps.klyph.core.fql.Attachment) Stream(com.abewy.android.apps.klyph.core.fql.Stream)

Example 12 with Stream

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

the class Klyph method getIntentForGraphObject.

public static Intent getIntentForGraphObject(Context context, GraphObject object) {
    Intent intent = null;
    if (object instanceof User) {
        User user = (User) object;
        if (user.getUid().length() == 0) {
            return null;
        }
        intent = new Intent();
        intent.setClass(context, UserActivity.class);
        intent.putExtra(KlyphBundleExtras.USER_ID, user.getUid());
        intent.putExtra(KlyphBundleExtras.USER_NAME, user.getName());
    } else if (object instanceof Friend) {
        Friend friend = (Friend) object;
        if (friend.getUid().length() == 0) {
            return null;
        }
        intent = new Intent();
        intent.setClass(context, UserActivity.class);
        intent.putExtra(KlyphBundleExtras.USER_ID, friend.getUid());
        intent.putExtra(KlyphBundleExtras.USER_NAME, friend.getName());
    } else if (object instanceof Page) {
        Page page = (Page) object;
        intent = new Intent();
        intent.setClass(context, PageActivity.class);
        intent.putExtra(KlyphBundleExtras.PAGE_ID, page.getPage_id());
        intent.putExtra(KlyphBundleExtras.PAGE_NAME, page.getName());
    } else if (object instanceof Event) {
        Event event = (Event) object;
        intent = new Intent();
        intent.setClass(context, EventActivity.class);
        intent.putExtra(KlyphBundleExtras.EVENT_ID, event.getEid());
        intent.putExtra(KlyphBundleExtras.EVENT_NAME, event.getName());
    } else if (object instanceof Stream) {
        Stream stream = (Stream) object;
        intent = new Intent();
        intent.setClass(context, StreamActivity.class);
        // intent.putExtra(KlyphBundleExtras.STREAM_ID, stream.getPost_id());
        intent.putExtra(KlyphBundleExtras.STREAM_PARCELABLE, stream);
    // intent.putExtra(CkoobafeBundleExtras.EVENT_NAME,
    // event.getName());
    } else if (object instanceof Group) {
        Group group = (Group) object;
        intent = new Intent();
        intent.setClass(context, GroupActivity.class);
        intent.putExtra(KlyphBundleExtras.GROUP_ID, group.getGid());
        intent.putExtra(KlyphBundleExtras.GROUP_NAME, group.getName());
    } else if (object instanceof Tag) {
        Tag tag = (Tag) object;
        if (tag.getType().equals("user") || tag.getType().equals(GraphType.FQL_USER.toString())) {
            intent = new Intent();
            intent.setClass(context, UserActivity.class);
            intent.putExtra(KlyphBundleExtras.USER_ID, tag.getId());
            intent.putExtra(KlyphBundleExtras.USER_NAME, tag.getName());
        } else if (tag.getType().equals("page") || tag.getType().equals(GraphType.FQL_PAGE.toString())) {
            intent = new Intent();
            intent.setClass(context, PageActivity.class);
            intent.putExtra(KlyphBundleExtras.PAGE_ID, tag.getId());
            intent.putExtra(KlyphBundleExtras.PAGE_NAME, tag.getName());
        }
    } else if (object instanceof Relative) {
        Relative user = (Relative) object;
        if (user.getUid().length() == 0) {
            return null;
        }
        intent = new Intent();
        intent.setClass(context, UserActivity.class);
        intent.putExtra(KlyphBundleExtras.USER_ID, user.getUid());
        intent.putExtra(KlyphBundleExtras.USER_NAME, user.getName());
    } else if (object instanceof FriendRequest) {
        FriendRequest fr = (FriendRequest) object;
        if (fr.getUid_from().length() == 0) {
            return null;
        }
        intent = new Intent();
        intent.setClass(context, UserActivity.class);
        intent.putExtra(KlyphBundleExtras.USER_ID, fr.getUid_from());
        intent.putExtra(KlyphBundleExtras.USER_NAME, fr.getUid_from_name());
    }
    return intent;
}
Also used : PageActivity(com.abewy.android.apps.klyph.app.PageActivity) Group(com.abewy.android.apps.klyph.core.fql.Group) Relative(com.abewy.android.apps.klyph.core.fql.User.Relative) User(com.abewy.android.apps.klyph.core.fql.User) Intent(android.content.Intent) Page(com.abewy.android.apps.klyph.core.fql.Page) FriendRequest(com.abewy.android.apps.klyph.core.fql.FriendRequest) UserActivity(com.abewy.android.apps.klyph.app.UserActivity) EventActivity(com.abewy.android.apps.klyph.app.EventActivity) GroupActivity(com.abewy.android.apps.klyph.app.GroupActivity) Friend(com.abewy.android.apps.klyph.core.fql.Friend) Event(com.abewy.android.apps.klyph.core.fql.Event) Stream(com.abewy.android.apps.klyph.core.fql.Stream) Tag(com.abewy.android.apps.klyph.core.fql.Tag)

Example 13 with Stream

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

the class NewsfeedAdapter method add.

@Override
public void add(GraphObject object) {
    if (object instanceof Stream) {
        final int size = getCount();
        if (size - lastAdPosition >= AD_INTERVAL) {
            lastAdPosition = size;
            super.add(new AdItem());
        }
    }
    super.add(object);
}
Also used : AdItem(com.abewy.klyph.items.AdItem) Stream(com.abewy.android.apps.klyph.core.fql.Stream)

Example 14 with Stream

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

the class StreamDeserializer method deserializeObject.

@Override
public GraphObject deserializeObject(JSONObject data) {
    Stream stream = new Stream();
    deserializePrimitives(stream, data);
    stream.setAttachment((Attachment) new AttachmentDeserializer().deserializeObject(getJsonObject(data, "attachment")));
    stream.setLike_info((LikeInfo) new LikesDeserializer().deserializeObject(getJsonObject(data, "like_info")));
    stream.setPrivacy((Privacy) new PrivacyDeserializer().deserializeObject(getJsonObject(data, "privacy")));
    stream.setComment_info((CommentInfo) new CommentsDeserializer().deserializeObject(getJsonObject(data, "comment_info")));
    stream.setLiked_pages(new PageDeserializer().deserializeArray(getJsonArray(data, "liked_pages"), Page.class));
    stream.setEvent((Event) new EventDeserializer().deserializeObject(getJsonObject(data, "event")));
    stream.setLink((Link) new LinkDeserializer().deserializeObject(getJsonObject(data, "link")));
    stream.setPhoto((Photo) new PhotoDeserializer().deserializeObject(getJsonObject(data, "photo")));
    stream.setVideo((Video) new VideoDeserializer().deserializeObject(getJsonObject(data, "video")));
    stream.setStatus((Status) new StatusDeserializer().deserializeObject(getJsonObject(data, "status")));
    stream.setApplication((Application) new ApplicationDeserializer().deserializeObject(getJsonObject(data, "application")));
    if (data.optJSONObject("parent_stream") != null)
        stream.setParent_stream((Stream) new StreamDeserializer().deserializeObject(getJsonObject(data, "parent_stream")));
    if (data.optJSONArray("message_tags") != null)
        stream.setMessage_tags(new TagDeserializer().deserializeMap(getJsonArray(data, "message_tags")));
    else
        stream.setMessage_tags(new TagDeserializer().deserializeMap(getJsonObject(data, "message_tags")));
    if (data.optJSONArray("description_tags") != null)
        stream.setDescription_tags(new TagDeserializer().deserializeMap(getJsonArray(data, "description_tags")));
    else
        stream.setDescription_tags(new TagDeserializer().deserializeMap(getJsonObject(data, "description_tags")));
    if (data.optJSONArray("tagged_tags") != null) {
        stream.setTagged_tags(new TagDeserializer().deserializeArray(getJsonArray(data, "tagged_tags"), Tag.class));
    } else
        stream.setTagged_tags(new ArrayList<Tag>());
    return stream;
}
Also used : ArrayList(java.util.ArrayList) Page(com.abewy.android.apps.klyph.core.fql.Page) Stream(com.abewy.android.apps.klyph.core.fql.Stream) Tag(com.abewy.android.apps.klyph.core.fql.Tag)

Example 15 with Stream

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

the class StreamSerializer method serializeObject.

@Override
public JSONObject serializeObject(GraphObject object) {
    JSONObject json = new JSONObject();
    serializePrimitives(object, json);
    Stream stream = (Stream) object;
    TagSerializer ts = new TagSerializer();
    ts.serializeMap(stream.getMessage_tags(), json, "message_tags");
    ts.serializeMap(stream.getDescription_tags(), json, "description_tags");
    AttachmentSerializer as = new AttachmentSerializer();
    LikesSerializer ls = new LikesSerializer();
    PrivacySerializer ps = new PrivacySerializer();
    CommentsSerializer cs = new CommentsSerializer();
    EventSerializer es = new EventSerializer();
    PageSerializer pas = new PageSerializer();
    LinkSerializer lis = new LinkSerializer();
    PhotoSerializer phs = new PhotoSerializer();
    VideoSerializer vs = new VideoSerializer();
    StatusSerializer ss = new StatusSerializer();
    ApplicationSerializer aps = new ApplicationSerializer();
    StreamSerializer sts = new StreamSerializer();
    try {
        json.put("attachment", as.serializeObject(stream.getAttachment()));
        json.put("privacy", ps.serializeObject(stream.getPrivacy()));
        json.put("like_info", ls.serializeObject(stream.getLike_info()));
        json.put("comment_info", cs.serializeObject(stream.getComment_info()));
        json.put("event", es.serializeObject(stream.getEvent()));
        json.put("liked_pages", pas.serializeArray(stream.getLiked_pages()));
        json.put("link", lis.serializeObject(stream.getLink()));
        json.put("photo", phs.serializeObject(stream.getPhoto()));
        json.put("video", vs.serializeObject(stream.getVideo()));
        json.put("status", ss.serializeObject(stream.getStatus()));
        json.put("application", aps.serializeObject(stream.getApplication()));
        if (stream.getParent_stream() != null)
            json.put("parent_stream", sts.serializeObject(stream.getParent_stream()));
    } catch (JSONException e) {
        Log.d("StreamSerializer", "JSONException " + e.getMessage());
    }
    return json;
}
Also used : JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) Stream(com.abewy.android.apps.klyph.core.fql.Stream)

Aggregations

Stream (com.abewy.android.apps.klyph.core.fql.Stream)16 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)7 ArrayList (java.util.ArrayList)4 Attachment (com.abewy.android.apps.klyph.core.fql.Attachment)3 Media (com.abewy.android.apps.klyph.core.fql.Media)3 Friend (com.abewy.android.apps.klyph.core.fql.Friend)2 Page (com.abewy.android.apps.klyph.core.fql.Page)2 Tag (com.abewy.android.apps.klyph.core.fql.Tag)2 Intent (android.content.Intent)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ListView (android.widget.ListView)1 KlyphAnimationAdapter (com.abewy.android.apps.klyph.adapter.animation.KlyphAnimationAdapter)1 StreamHolder (com.abewy.android.apps.klyph.adapter.holder.StreamHolder)1 StreamButtonBar (com.abewy.android.apps.klyph.adapter.subAdapter.StreamButtonBar)1 StreamLink (com.abewy.android.apps.klyph.adapter.subAdapter.StreamLink)1 StreamPhoto (com.abewy.android.apps.klyph.adapter.subAdapter.StreamPhoto)1 StreamStatus (com.abewy.android.apps.klyph.adapter.subAdapter.StreamStatus)1 EventActivity (com.abewy.android.apps.klyph.app.EventActivity)1 GroupActivity (com.abewy.android.apps.klyph.app.GroupActivity)1