Search in sources :

Example 1 with Link

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

the class StreamLink method manageLink.

private void manageLink(final StreamHolder holder, Stream stream) {
    final Link link = stream.getLink();
    if (!stream.getActor_id().equals(link.getOwner()))
        new StreamHeader(specialLayout).mergeData(holder, stream, link);
    new StreamButtonBar(getParentAdapter(), specialLayout).mergeData(holder, stream, link);
    holder.getPostLinkBackground().setVisibility(View.VISIBLE);
    if (link.getPicture().length() > 0) {
        loadImage(holder.getPostLinkBackground(), getLargeImageUrlForLink(link.getPicture()), R.drawable.stream_link_placeholder, stream);
    } else {
        holder.getPostLinkBackground().setImageResource(R.drawable.stream_link_placeholder);
    }
    if (link.getOwner_comment().length() > 0) {
        holder.getMessage().setText(link.getOwner_comment());
        holder.getMessage().setVisibility(View.VISIBLE);
    }
    if (link.getTitle().length() > 0) {
        holder.getPostName().setText(link.getTitle());
        holder.getPostName().setVisibility(View.VISIBLE);
    }
    if (link.getCaption().length() > 0) {
        holder.getPostCaption().setText(link.getCaption());
        holder.getPostCaption().setVisibility(View.VISIBLE);
    } else if (!link.isEventLink()) {
        holder.getPostCaption().setText(link.getUrl());
        holder.getPostCaption().setVisibility(View.VISIBLE);
    }
    if (link.getSummary().length() > 0) {
        holder.getPostDescription().setText(link.getSummary());
        holder.getPostDescription().setVisibility(View.VISIBLE);
    }
    final View view = holder.getAuthorProfileImage();
    holder.getStreamLink().setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (link.isEventLink()) {
                Intent intent = Klyph.getIntentForParams(holder.getStory().getContext(), link.getEventId(), link.getTitle(), "event");
                holder.getStory().getContext().startActivity(intent);
            } else {
                PhoneUtil.openURL(getContext(view), link.getUrl());
            }
        }
    });
    holder.getStreamLink().setVisibility(View.VISIBLE);
}
Also used : OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) View(android.view.View) RatioImageView(com.abewy.android.extended.widget.RatioImageView) Link(com.abewy.android.apps.klyph.core.fql.Link)

Example 2 with Link

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

the class StreamLink method manageVideoLink.

private void manageVideoLink(StreamHolder holder, Stream stream) {
    final Link link = stream.getLink();
    final View view = holder.getAuthorProfileImage();
    if (!stream.getActor_id().equals(link.getOwner()))
        new StreamHeader(specialLayout).mergeData(holder, stream, link);
    new StreamButtonBar(getParentAdapter(), specialLayout).mergeData(holder, stream, link);
    String url = "";
    int width = -1;
    int height = -1;
    if (link.isYoutubeLink()) {
        url = YoutubeUtil.getThumbUrl(link.getUrl());
        Log.d("StreamLink", "Youtube Link = " + link.getUrl() + " " + url);
        width = YoutubeUtil.THUMB_WIDTH;
        height = YoutubeUtil.THUMB_HEIGHT;
    } else if (link.isDailymotionLink()) {
        url = DailymotionUtil.getThumbUrl(link.getUrl());
        width = DailymotionUtil.THUMB_WIDTH;
        height = DailymotionUtil.THUMB_HEIGHT;
    } else if (link.isVimeoLink()) {
        url = VimeoUtil.getThumbUrl(link.getUrl());
        width = VimeoUtil.THUMB_WIDTH;
        height = VimeoUtil.THUMB_HEIGHT;
    }
    RatioImageView ratioImageView = (RatioImageView) holder.getPostPhoto();
    ratioImageView.setImageSize(width, height);
    loadImage(holder.getPostPhoto(), url, stream);
    holder.getPostPhoto().setVisibility(View.VISIBLE);
    holder.getPostVideoPlay().setVisibility(View.VISIBLE);
    ((ViewGroup) holder.getPostPhoto().getParent()).setVisibility(View.VISIBLE);
    if (link.getTitle().length() > 0) {
        holder.getVideoTitle().setText(link.getTitle());
        holder.getVideoTitle().setVisibility(View.VISIBLE);
        ((ViewGroup) holder.getVideoTitle().getParent()).setVisibility(View.VISIBLE);
    }
    if (link.getSummary().length() > 0) {
        holder.getMessage().setText(link.getSummary());
        holder.getMessage().setVisibility(View.VISIBLE);
    }
    holder.getPostPhoto().setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String url = link.getUrl();
            if (YoutubeUtil.isYoutubeLink(url) && YoutubeUtil.getVideoIdFromUrl(url).length() > 0) {
                Log.d("StreamLink", "isYoutubeVideo " + YoutubeUtil.getVideoIdFromUrl(url));
                try {
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + YoutubeUtil.getVideoIdFromUrl(url)));
                    getContext(view).startActivity(intent);
                } catch (ActivityNotFoundException ex) {
                    Log.d("StreamLink", "ActivityNotFoundException");
                    PhoneUtil.openURL(getContext(view), url);
                }
            } else {
                Log.d("StreamLink", "not YoutubeVideo");
                PhoneUtil.openURL(getContext(view), url);
            }
        }
    });
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) ViewGroup(android.view.ViewGroup) OnClickListener(android.view.View.OnClickListener) RatioImageView(com.abewy.android.extended.widget.RatioImageView) Intent(android.content.Intent) View(android.view.View) RatioImageView(com.abewy.android.extended.widget.RatioImageView) Link(com.abewy.android.apps.klyph.core.fql.Link)

Example 3 with Link

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

the class LinkDeserializer method deserializeObject.

@Override
public GraphObject deserializeObject(JSONObject data) {
    Link link = new Link();
    deserializePrimitives(link, data);
    link.setComment_info((CommentInfo) new StreamDeserializer.CommentsDeserializer().deserializeObject(getJsonObject(data, "comment_info")));
    link.setLike_info((LikeInfo) new LikesDeserializer().deserializeObject(getJsonObject(data, "like_info")));
    link.setPrivacy((Privacy) new PrivacyDeserializer().deserializeObject(getJsonObject(data, "privacy")));
    return link;
}
Also used : Link(com.abewy.android.apps.klyph.core.fql.Link)

Example 4 with Link

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

the class LinkSerializer method serializeObject.

@Override
public JSONObject serializeObject(GraphObject object) {
    JSONObject json = new JSONObject();
    serializePrimitives(object, json);
    Link link = (Link) object;
    LikesSerializer ls = new LikesSerializer();
    StreamSerializer.CommentsSerializer cs = new StreamSerializer.CommentsSerializer();
    PrivacySerializer ps = new PrivacySerializer();
    try {
        json.put("comment_info", cs.serializeObject(link.getComment_info()));
        json.put("privacy", ps.serializeObject(link.getPrivacy()));
        json.put("like_info", ls.serializeObject(link.getLike_info()));
    } catch (JSONException e) {
        Log.d("LinkSerializer", "JSONException " + e.getMessage());
    }
    return json;
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) Link(com.abewy.android.apps.klyph.core.fql.Link)

Example 5 with Link

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

the class StreamButtonBar method handleShareAction.

private void handleShareAction(final IStreamHolder holder, final Stream stream) {
    Intent intent = new Intent(getContext(holder.getShareButton()), PostActivity.class);
    intent.putExtra(KlyphBundleExtras.SHARE, true);
    Attachment att = stream.getAttachment();
    if (stream.isLink()) {
        Link link = stream.getLink();
        intent.putExtra(KlyphBundleExtras.SHARE_LINK_URL, link.getUrl());
        intent.putExtra(KlyphBundleExtras.SHARE_LINK_IMAGE_URL, link.getPicture());
        intent.putExtra(KlyphBundleExtras.SHARE_LINK_NAME, link.getTitle());
        intent.putExtra(KlyphBundleExtras.SHARE_LINK_DESC, link.getSummary());
    } else if (stream.isPhoto()) /* || att.isPhoto() */
    {
        Photo photo = stream.getPhoto();
        intent.putExtra(KlyphBundleExtras.SHARE_PHOTO_ID, stream.isPhoto() ? photo.getObject_id() : att.getFb_object_id());
    } else if (stream.isVideo()) /* || att.isVideo() */
    {
        Video video = stream.getVideo();
        intent.putExtra(KlyphBundleExtras.SHARE_VIDEO_ID, stream.isVideo() ? video.getVid() : att.getFb_object_id());
    } else /*
		 * else if (att.isAlbum())
		 * {
		 * intent.putExtra(KlyphBundleExtras.SHARE_ALBUM_ID, att.getFb_object_id());
		 * }
		 */
    {
        intent.putExtra(KlyphBundleExtras.SHARE_POST_ID, stream);
        Log.d("StreamButtonBar", "Share something but I do not what");
    }
    getContext(holder.getShareButton()).startActivity(intent);
}
Also used : Video(com.abewy.android.apps.klyph.core.fql.Video) Intent(android.content.Intent) Attachment(com.abewy.android.apps.klyph.core.fql.Attachment) Photo(com.abewy.android.apps.klyph.core.fql.Photo) Link(com.abewy.android.apps.klyph.core.fql.Link)

Aggregations

Link (com.abewy.android.apps.klyph.core.fql.Link)7 Intent (android.content.Intent)4 Photo (com.abewy.android.apps.klyph.core.fql.Photo)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 View (android.view.View)2 OnClickListener (android.view.View.OnClickListener)2 Attachment (com.abewy.android.apps.klyph.core.fql.Attachment)2 Video (com.abewy.android.apps.klyph.core.fql.Video)2 RatioImageView (com.abewy.android.extended.widget.RatioImageView)2 ViewGroup (android.view.ViewGroup)1 Media (com.abewy.android.apps.klyph.core.fql.Media)1 Status (com.abewy.android.apps.klyph.core.fql.Status)1 Stream (com.abewy.android.apps.klyph.core.fql.Stream)1 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1