Search in sources :

Example 46 with GraphObject

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();
    }
}
Also used : KlyphAnimationAdapter(com.abewy.android.apps.klyph.adapter.animation.KlyphAnimationAdapter) ArrayList(java.util.ArrayList) Stream(com.abewy.android.apps.klyph.core.fql.Stream) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) View(android.view.View) ListView(android.widget.ListView)

Example 47 with GraphObject

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);
    }
}
Also used : Intent(android.content.Intent) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 48 with GraphObject

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;
}
Also used : JSONObject(org.json.JSONObject) FriendRequestDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.FriendRequestDeserializer) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 49 with GraphObject

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++;
    }
}
Also used : GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 50 with GraphObject

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;
}
Also used : JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) FriendDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.FriendDeserializer)

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