Search in sources :

Example 6 with Link

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

the class StreamButtonBar method handleShareWithAction.

private void handleShareWithAction(final IStreamHolder holder, final Stream stream) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    Attachment att = stream.getAttachment();
    if (stream.isLink()) {
        Link link = stream.getLink();
        intent.putExtra(Intent.EXTRA_TEXT, link.getUrl());
        intent.putExtra(Intent.EXTRA_SUBJECT, link.getTitle());
        intent.setType("text/plain");
    } else if (stream.isPhoto()) /* || att.isPhoto() */
    {
        Photo photo = stream.getPhoto();
        intent.putExtra(Intent.EXTRA_TEXT, photo.getLargestImageURL());
        if (photo.getCaption().length() > 0)
            intent.putExtra(Intent.EXTRA_SUBJECT, photo.getCaption());
        else if (stream.getMessage().length() > 0)
            intent.putExtra(Intent.EXTRA_SUBJECT, stream.getMessage());
        intent.setType("text/plain");
    // 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(Intent.EXTRA_TEXT, video.getSrc_hq());
        if (video.getTitle().length() > 0)
            intent.putExtra(Intent.EXTRA_SUBJECT, video.getTitle());
        else if (stream.getMessage().length() > 0)
            intent.putExtra(Intent.EXTRA_SUBJECT, stream.getMessage());
        intent.setType("text/plain");
    // 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());
		 * }
		 */
    if (att.getMedia().size() == 1) {
        Media m = att.getMedia().get(0);
        intent.putExtra(Intent.EXTRA_TEXT, m.getSrc());
        intent.putExtra(Intent.EXTRA_SUBJECT, m.getAlt());
        intent.setType("text/plain");
    } else {
        if (stream.getMessage().length() > 0) {
            intent.putExtra(Intent.EXTRA_TEXT, stream.getMessage());
            intent.setType("text/plain");
        } else if (stream.getDescription().length() > 0) {
            intent.putExtra(Intent.EXTRA_TEXT, stream.getDescription());
            intent.setType("text/plain");
        }
    }
    try {
        getContext(holder.getShareButton()).startActivity(intent);
    } catch (ActivityNotFoundException e) {
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Video(com.abewy.android.apps.klyph.core.fql.Video) Media(com.abewy.android.apps.klyph.core.fql.Media) 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)

Example 7 with Link

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

the class StreamFragment method populate.

@Override
protected void populate(List<GraphObject> data) {
    if (data.size() > 0) {
        if (isFirstLoad()) {
            if (isStreamAvailableOnLaunch) {
                GraphObject object = data.get(0);
                if (object instanceof Status) {
                    initVariables((Status) object);
                } else if (object instanceof Link) {
                    initVariables((Link) object);
                } else if (object instanceof Photo) {
                    initVariables((Photo) object);
                }
                // Remove loading
                getAdapter().removeAt(1);
                likeTitle = new StreamLikeCount();
                getAdapter().add(likeTitle);
                refreshLikeCount();
                data.remove(0);
                if (stream.getComment_info().getCan_comment()) {
                    sendButton.setVisibility(View.VISIBLE);
                    sendEditText.setVisibility(View.VISIBLE);
                }
                if (getActivity() != null)
                    ((FragmentActivity) getActivity()).invalidateOptionsMenu();
                setRequestType(Query.COMMENTS);
                setNoMoreData(false);
                endLoading();
                refresh();
            } else {
                if (data.get(0) instanceof Stream) {
                    Stream stream = (Stream) data.get(0);
                    // setIsFirstLoad(true);
                    setStreamAndLoad(stream);
                    refresh();
                } else {
                    super.populate(new ArrayList<GraphObject>());
                }
            }
        } else {
            super.populate(data);
        }
    } else {
        if (isFirstLoad() && isStreamAvailableOnLaunch) {
            // Remove loading
            getAdapter().removeAt(1);
        }
        super.populate(data);
    }
    setNoMoreData(!isFirstLoad() && (data.size() == 0 || (getRequest().getPagingNext() == null || getRequest().getPagingNext().length() == 0)));
    if (getAdapter().getCount() > 2) {
        setOffset(getAfterCursor());
    }
}
Also used : Status(com.abewy.android.apps.klyph.core.fql.Status) Photo(com.abewy.android.apps.klyph.core.fql.Photo) Stream(com.abewy.android.apps.klyph.core.fql.Stream) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) 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