Search in sources :

Example 6 with Stream

use of com.abewy.android.apps.klyph.core.fql.Stream 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)

Example 7 with Stream

use of com.abewy.android.apps.klyph.core.fql.Stream 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)

Example 8 with Stream

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

the class StreamListFragment method storeSessionStreams.

private void storeSessionStreams() {
    if (getAdapter() != null && getAdapter().getCount() > 0) {
        // Make a copy of the list
        List<GraphObject> streams = new ArrayList<GraphObject>();
        // Add only the streams (e.g. no progress or error items)
        for (GraphObject graphObject : getAdapter().getItems()) {
            if (graphObject instanceof Stream)
                streams.add(graphObject);
        }
        KlyphData.setLastStreams(streams);
    }
}
Also used : ArrayList(java.util.ArrayList) Stream(com.abewy.android.apps.klyph.core.fql.Stream) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 9 with Stream

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

the class StreamListFragment method load.

@Override
public void load() {
    if (isFirstLoad) {
        if (KlyphData.getLastStreams() != null) {
            populate(KlyphData.getLastStreams());
            if (stream_position_id != null) {
                for (GraphObject graphObject : getAdapter().getItems()) {
                    if (graphObject instanceof Stream && stream_position_id.equals(((Stream) graphObject).getPost_id())) {
                        getListView().setSelection(getAdapter().getItemPosition(graphObject));
                    }
                }
            }
            setNoMoreData(false);
        } else {
            readTask = new ReadDataTask();
            readTask.execute();
        }
    } else {
        super.load();
    }
}
Also used : Stream(com.abewy.android.apps.klyph.core.fql.Stream) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 10 with Stream

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

the class StreamListFragment method onPause.

@Override
public void onPause() {
    if (getListView() != null && getAdapter() != null) {
        int pos = getListView().getFirstVisiblePosition();
        GraphObject o = getAdapter().getItem(pos);
        if (pos < getAdapter().getCount() && o instanceof Stream) {
            stream_position_id = ((Stream) o).getPost_id();
        } else if (pos > 0) {
            pos--;
            if (pos < getAdapter().getCount() && o instanceof Stream)
                stream_position_id = ((Stream) o).getPost_id();
        }
    }
    setPullToRefreshRefreshing(false);
    super.onPause();
}
Also used : Stream(com.abewy.android.apps.klyph.core.fql.Stream) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

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