Search in sources :

Example 96 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject 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 97 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.

the class ImageFragment method populate.

@Override
protected void populate(List<GraphObject> data) {
    if (data.size() > 0) {
        GraphObject object = data.get(0);
        if (object instanceof Photo) {
            Photo photo = (Photo) data.get(0);
            // if (this.photo == null)
            // {
            setPhoto(photo);
            // }
            getAdapter().add(photo);
            likeTitle = new StreamLikeCount();
            getAdapter().add(likeTitle);
            refreshLikeCount();
            data.remove(0);
            super.populate(data);
            setRequestType(Query.COMMENTS);
            setNoMoreData(false);
            (getActivity()).invalidateOptionsMenu();
            refresh();
        } else {
            super.populate(data);
            setNoMoreData(!isFirstLoad() && (data.size() == 0 || (getRequest().getPagingNext() == null || getRequest().getPagingNext().length() == 0)));
            setOffset(getAfterCursor());
        }
    } else {
        super.populate(data);
        setNoMoreData(!isFirstLoad() && (data.size() == 0 || (getRequest().getPagingNext() == null || getRequest().getPagingNext().length() == 0)));
        setOffset(getAfterCursor());
    }
}
Also used : Photo(com.abewy.android.apps.klyph.core.fql.Photo) StreamLikeCount(com.abewy.android.apps.klyph.fragment.StreamFragment.StreamLikeCount) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 98 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject 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 99 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject 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 100 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject 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

GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)101 ArrayList (java.util.ArrayList)71 JSONArray (org.json.JSONArray)41 JSONObject (org.json.JSONObject)16 FriendDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.FriendDeserializer)11 PhotoDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.PhotoDeserializer)9 MultiObjectAdapter (com.abewy.android.apps.klyph.adapter.MultiObjectAdapter)7 Stream (com.abewy.android.apps.klyph.core.fql.Stream)7 View (android.view.View)6 KlyphNotification (com.abewy.android.apps.klyph.KlyphNotification)6 Notification (com.abewy.android.apps.klyph.core.fql.Notification)6 Photo (com.abewy.android.apps.klyph.core.fql.Photo)6 JSONException (org.json.JSONException)6 StreamDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.StreamDeserializer)5 Intent (android.content.Intent)4 ListView (android.widget.ListView)4 Event (com.abewy.android.apps.klyph.core.fql.Event)4 AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)4 TextButtonItem (com.abewy.klyph.items.TextButtonItem)4 AbsListView (android.widget.AbsListView)3