Search in sources :

Example 1 with Media

use of com.abewy.android.apps.klyph.core.fql.Media 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 2 with Media

use of com.abewy.android.apps.klyph.core.fql.Media 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 3 with Media

use of com.abewy.android.apps.klyph.core.fql.Media 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 4 with Media

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

the class MediaSerializer method serializeObject.

@Override
public JSONObject serializeObject(GraphObject object) {
    JSONObject json = new JSONObject();
    serializePrimitives(object, json);
    Media media = (Media) object;
    PhotoSerializer ps = new PhotoSerializer();
    VideoSerializer vs = new VideoSerializer();
    SwfSerializer swfs = new SwfSerializer();
    try {
        json.put("photo", ps.serializeObject(media.getPhoto()));
        json.put("video", vs.serializeObject(media.getVideo()));
        json.put("swf", swfs.serializeObject(media.getSwf()));
    } catch (JSONException e) {
        Log.d("MediaSerializer", "JsonException " + e);
    }
    return json;
}
Also used : JSONObject(org.json.JSONObject) Media(com.abewy.android.apps.klyph.core.fql.Media) JSONException(org.json.JSONException)

Example 5 with Media

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

the class MediaDeserializer method deserializeObject.

@Override
public GraphObject deserializeObject(JSONObject data) {
    Media media = new Media();
    deserializePrimitives(media, data);
    media.setPhoto((Photo) new PhotoDeserializer().deserializeObject(getJsonObject(data, "photo")));
    media.setVideo((Video) new VideoDeserializer().deserializeObject(getJsonObject(data, "video")));
    media.setSwf((Swf) new SwfDeserializer().deserializeObject(getJsonObject(data, "swf")));
    return media;
}
Also used : Media(com.abewy.android.apps.klyph.core.fql.Media)

Aggregations

Media (com.abewy.android.apps.klyph.core.fql.Media)10 Attachment (com.abewy.android.apps.klyph.core.fql.Attachment)8 Intent (android.content.Intent)3 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 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 Link (com.abewy.android.apps.klyph.core.fql.Link)1 Photo (com.abewy.android.apps.klyph.core.fql.Photo)1 Video (com.abewy.android.apps.klyph.core.fql.Video)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 ArrayList (java.util.ArrayList)1 JSONException (org.json.JSONException)1