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());
}
}
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());
}
}
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();
}
}
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);
}
}
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();
}
Aggregations