use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class StreamListFragment method populateNewest.
@Override
protected void populateNewest(List<GraphObject> data) {
int n = data.size();
if (n > 0) {
int index = getListView().getFirstVisiblePosition();
View v = getListView().getChildAt(index);
int top = v == null ? 0 : v.getTop();
int lastIndex = -1;
if (KlyphPreferences.getNewsfeedGoToTop() == false) {
List<GraphObject> list = new ArrayList<GraphObject>();
list.addAll(getAdapter().getItems());
// Looking for a matching post
outer: for (int i = 0; i < n; i++) {
Stream stream = (Stream) data.get(i);
for (int j = 0, m = list.size(); j < m; j++) {
if (list.get(j) instanceof Stream) {
Stream s = (Stream) list.get(j);
Log.d("StreamListFragment", "populateNewest: " + stream.getPost_id() + " " + s.getPost_id());
if (stream.getPost_id().equals(s.getPost_id())) {
lastIndex = i;
// list.add(stream);
break outer;
}
}
}
}
Log.d("StreamListFragment", "populateNewest: " + lastIndex);
// If no match, then insert all the data
if (lastIndex == -1)
lastIndex = data.size();
// Insert filtered data
for (int i = lastIndex - 1; i >= 0; i--) {
list.add(0, data.get(i));
}
getAdapter().clear(false);
getAdapter().addAll(list);
} else {
getAdapter().clear(false);
getAdapter().addAll(data);
setOffset(((Stream) data.get(data.size() - 1)).getCreated_time());
}
if (getListAdapter() instanceof KlyphAnimationAdapter) {
int firstVisiblePosition = getListView().getFirstVisiblePosition();
int lastVisiblePosition = getListView().getLastVisiblePosition();
if (firstVisiblePosition != lastVisiblePosition)
((KlyphAnimationAdapter) getListAdapter()).deactivateNext(lastVisiblePosition - firstVisiblePosition);
else
((KlyphAnimationAdapter) getListAdapter()).deactivateNext(1);
}
getAdapter().notifyDataSetChanged();
if (KlyphPreferences.getNewsfeedGoToTop() == false) {
getListView().setSelectionFromTop(lastIndex, top);
}
}
setNewestLoading(false);
setPullToRefreshRefreshing(false);
if (data.size() > 0) {
storeSessionStreams();
storeData();
}
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class UserAbout method onGridItemClick.
@Override
public void onGridItemClick(KlyphGridView l, View v, int position, long id) {
GraphObject data = (GraphObject) l.getItemAtPosition(position);
Intent intent = Klyph.getIntentForGraphObject(getActivity(), data);
if (intent != null) {
startActivity(intent);
}
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class FriendsRequestNotificationRequest method handleResult.
@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
JSONArray data = result[0];
JSONArray urls = result[1];
JSONArray names = result[2];
for (int i = 0; i < urls.length(); i++) {
JSONObject jsonObject = urls.optJSONObject(i);
try {
jsonObject.putOpt("id", String.valueOf(jsonObject.opt("id")));
} catch (JSONException e) {
// e.printStackTrace();
}
}
for (int i = 0; i < names.length(); i++) {
JSONObject jsonObject = names.optJSONObject(i);
try {
jsonObject.putOpt("id", String.valueOf(jsonObject.opt("id")));
} catch (JSONException e) {
// e.printStackTrace();
}
}
assocData(data, urls, "uid_from", "id", "uid_from_pic", "url");
assocData(data, names, "uid_from", "id", "uid_from_name", "name");
FriendRequestDeserializer deserializer = new FriendRequestDeserializer();
ArrayList<GraphObject> friendRequests = (ArrayList<GraphObject>) deserializer.deserializeArray(data);
return friendRequests;
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class FriendPickerActivity method refreshCheckedViews.
private void refreshCheckedViews() {
int i = 0;
for (GraphObject graphObject : getAdapter().getItems()) {
getListView().setItemChecked(i, graphObject.isSelected());
i++;
}
}
use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.
the class AllFriendsRequest method handleResult.
@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
JSONArray friends = result[0];
JSONArray pics = result[1];
assocData(friends, pics, "uid", "id", "pic", "url");
FriendDeserializer deserializer = new FriendDeserializer();
ArrayList<GraphObject> list = (ArrayList<GraphObject>) deserializer.deserializeArray(friends);
setHasMoreData(false);
return list;
}
Aggregations