Search in sources :

Example 1 with Status

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

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

the class StreamStatus method mergeData.

public void mergeData(StreamHolder holder, Stream stream) {
    final Status status = stream.getStatus();
    new StreamHeader(specialLayout).mergeData(holder, stream, status);
    new StreamButtonBar(getParentAdapter(), specialLayout).mergeData(holder, stream, status);
    if (status.getMessage().length() > 0) {
        holder.getMessage().setText(status.getMessage());
        holder.getMessage().setVisibility(View.VISIBLE);
    }
}
Also used : Status(com.abewy.android.apps.klyph.core.fql.Status)

Example 3 with Status

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

the class StatusDeserializer method deserializeObject.

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

Example 4 with Status

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

the class StatusSerializer method serializeObject.

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

Aggregations

Status (com.abewy.android.apps.klyph.core.fql.Status)4 Link (com.abewy.android.apps.klyph.core.fql.Link)1 Photo (com.abewy.android.apps.klyph.core.fql.Photo)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