Search in sources :

Example 1 with Attachment

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

the class AttachmentDeserializer method deserializeObject.

@Override
public GraphObject deserializeObject(JSONObject data) {
    Attachment attachment = new Attachment();
    deserializePrimitives(attachment, data);
    attachment.setMedia(new MediaDeserializer().deserializeArray(getJsonArray(data, "media"), Media.class));
    attachment.setFb_checkin((Checkin) new CheckinDeserializer().deserializeObject(getJsonObject(data, "fb_checkin")));
    return attachment;
}
Also used : Media(com.abewy.android.apps.klyph.core.fql.Media) Attachment(com.abewy.android.apps.klyph.core.fql.Attachment)

Example 2 with Attachment

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

the class AttachmentSerializer method serializeObject.

@Override
public JSONObject serializeObject(GraphObject object) {
    JSONObject json = new JSONObject();
    serializePrimitives(object, json);
    Attachment attachment = (Attachment) object;
    CheckinSerializer cs = new CheckinSerializer();
    MediaSerializer ms = new MediaSerializer();
    try {
        json.putOpt("fb_checkin", cs.serializeObject(attachment.getFb_checkin()));
        json.putOpt("media", ms.serializeArray(attachment.getMedia()));
    } catch (JSONException e) {
        Log.d("AttachmentSerializer", "JSONException" + e.getMessage());
    }
    return json;
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) Attachment(com.abewy.android.apps.klyph.core.fql.Attachment)

Example 3 with Attachment

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

the class StreamAdapter2 method manageAttachment.

private void manageAttachment(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(holder, stream);
        buttonBarAdapter.mergeData(holder, stream);
    } else if (stream.getLink().isEventLink()) {
        linkAdapter.mergeData(holder, stream, stream.getLink());
    } else if (stream.getType() == 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 4 with Attachment

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

the class StreamLink method manageAttachmentLink.

private void manageAttachmentLink(StreamHolder holder, Stream stream) {
    final Attachment attachment = stream.getAttachment();
    final Media media = attachment.getMedia().get(0);
    if (media.getAlt().length() == 0 && media.getHref().length() == 0 && attachment.getName().length() == 0 && attachment.getCaption().length() == 0 && attachment.getDescription().length() == 0)
        return;
    holder.getPostLinkBackground().setVisibility(View.VISIBLE);
    loadImage(holder.getPostLinkBackground(), getLargeImageUrlForLink(media.getSrc()), R.drawable.stream_link_placeholder, stream);
    holder.getPostLinkBackground().setVisibility(View.VISIBLE);
    if (attachment.getName().length() > 0) {
        holder.getPostName().setText(attachment.getName());
        holder.getPostName().setVisibility(View.VISIBLE);
    }
    if (attachment.getCaption().length() > 0) {
        holder.getPostCaption().setText(attachment.getCaption());
        holder.getPostCaption().setVisibility(View.VISIBLE);
    }
    if (attachment.getDescription().length() > 0) {
        holder.getPostDescription().setText(attachment.getDescription());
        holder.getPostDescription().setVisibility(View.VISIBLE);
    }
    if (media.isVideo()) {
        holder.getPostPicturePlay().setVisibility(View.VISIBLE);
    }
    final View view = holder.getAuthorProfileImage();
    holder.getStreamLink().setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            PhoneUtil.openURL(getContext(view), attachment.getHref());
        }
    });
    holder.getStreamLink().setVisibility(View.VISIBLE);
}
Also used : Media(com.abewy.android.apps.klyph.core.fql.Media) OnClickListener(android.view.View.OnClickListener) Attachment(com.abewy.android.apps.klyph.core.fql.Attachment) View(android.view.View) RatioImageView(com.abewy.android.extended.widget.RatioImageView)

Example 5 with Attachment

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

the class PostShare method initWithIntent.

public void initWithIntent(Intent intent) {
    String photoId = intent.getStringExtra(KlyphBundleExtras.SHARE_PHOTO_ID);
    String videoId = intent.getStringExtra(KlyphBundleExtras.SHARE_VIDEO_ID);
    String albumId = intent.getStringExtra(KlyphBundleExtras.SHARE_ALBUM_ID);
    Stream post = intent.getParcelableExtra(KlyphBundleExtras.SHARE_POST_ID);
    String linkUrl = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_URL);
    if (photoId != null) {
        url = PHOTO + photoId;
        new AsyncRequest(Query.PHOTO, photoId, "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                onPhotoRequestComplete(response);
            }
        }).execute();
    } else if (videoId != null) {
        url = VIDEO + videoId;
        new AsyncRequest(Query.VIDEO, videoId, "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                onVideoRequestComplete(response);
            }
        }).execute();
    } else if (albumId != null) {
        url = ALBUM + albumId;
        new AsyncRequest(Query.ALBUM, albumId, "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                onAlbumRequestComplete(response);
            }
        }).execute();
    } else if (post != null) {
        url = post.getPermalink();
        if (post.isStatus()) {
            fillViews(post.getActor_name(), post.getMessage(), post.getActor_pic());
            getActivity().setTitle(R.string.post_share_status);
        } else {
            Attachment att = post.getAttachment();
            if (att.isPhoto() || att.isVideo() || att.isAlbum()) {
                Media media = att.getMedia().get(0);
                if (att.isAlbum()) {
                    fillViews(post.getActor_name(), att.getName(), media.getSrc());
                } else {
                    fillViews(post.getActor_name(), media.getAlt(), media.getSrc());
                }
                if (att.isPhoto())
                    getActivity().setTitle(R.string.post_share_photo);
                else if (att.isVideo())
                    getActivity().setTitle(R.string.post_share_video);
                else
                    getActivity().setTitle(R.string.post_share_album);
            } else {
                getActivity().setTitle(R.string.post_share_status);
                fillViews(post.getActor_name(), post.getMessage(), post.getActor_pic());
            }
        }
    } else if (linkUrl != null) {
        isLink = true;
        url = linkUrl;
        imageUrl = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_IMAGE_URL);
        String linkName = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_NAME);
        String linkDesc = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_DESC);
        fillViews(linkName, linkDesc, imageUrl);
        getActivity().setTitle(R.string.post_share_link);
    } else {
        Log.d("PostShare", "All null");
    }
    if (isLink == false) {
        ((ViewGroup) spinner.getParent()).setVisibility(View.GONE);
    } else {
        SpinnerAdapter adapter = new SpinnerAdapter(getActivity());
        spinner.setAdapter(adapter);
        Friend friend = new Friend();
        friend.setName(getString(R.string.post_share_on_my_wall));
        adapter.add(friend);
        friend = new Friend();
        friend.setName(getString(R.string.post_share_on_friend_wall));
        adapter.add(friend);
        adapter.notifyDataSetChanged();
        spinner.setSelection(0);
        spinner.setOnItemSelectedListener(this);
        previousPosition = 0;
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) Friend(com.abewy.android.apps.klyph.core.fql.Friend) ViewGroup(android.view.ViewGroup) Media(com.abewy.android.apps.klyph.core.fql.Media) Stream(com.abewy.android.apps.klyph.core.fql.Stream) Attachment(com.abewy.android.apps.klyph.core.fql.Attachment)

Aggregations

Attachment (com.abewy.android.apps.klyph.core.fql.Attachment)12 Media (com.abewy.android.apps.klyph.core.fql.Media)8 Intent (android.content.Intent)4 View (android.view.View)3 Stream (com.abewy.android.apps.klyph.core.fql.Stream)3 RatioImageView (com.abewy.android.extended.widget.RatioImageView)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 OnClickListener (android.view.View.OnClickListener)2 ViewGroup (android.view.ViewGroup)2 Link (com.abewy.android.apps.klyph.core.fql.Link)2 Photo (com.abewy.android.apps.klyph.core.fql.Photo)2 Video (com.abewy.android.apps.klyph.core.fql.Video)2 ArrayList (java.util.ArrayList)2 AlbumActivity (com.abewy.android.apps.klyph.app.AlbumActivity)1 ImageActivity (com.abewy.android.apps.klyph.app.ImageActivity)1 Friend (com.abewy.android.apps.klyph.core.fql.Friend)1 Tag (com.abewy.android.apps.klyph.core.fql.Tag)1 Response (com.abewy.android.apps.klyph.core.request.Response)1 AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)1 AdapterView (it.sephiroth.android.library.widget.AdapterView)1