Search in sources :

Example 91 with GraphObject

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

the class Notifications method onListItemClick.

@Override
public void onListItemClick(ListView gridView, View view, int position, long id) {
    GraphObject graphObject = getAdapter().getItem(position);
    if (graphObject instanceof Notification) {
        Notification notification = (Notification) graphObject;
        if (notification.getIs_unread() == true) {
            setNotificationRead(notification);
            ((NotificationsListener) getActivity()).onNewNotifications();
        }
        Intent intent = KlyphNotification.getIntentForNotification(getActivity(), notification);
        if (intent != null) {
            startActivity(intent);
        }
    } else if (graphObject instanceof FriendRequest) {
        /*
			 * new AsyncRequest(Query.POST_READ_NOTIFICATION, ((FriendRequest) graphObject).getUid_from(), "", new AsyncRequest.Callback() {
			 * 
			 * @Override
			 * public void onComplete(Response response)
			 * {
			 * Log.d("NotificationsNotifications", "result " + response.getError());
			 * }
			 * }).execute();
			 */
        startActivity(Klyph.getIntentForGraphObject(getActivity(), graphObject));
    }
}
Also used : Intent(android.content.Intent) FriendRequest(com.abewy.android.apps.klyph.core.fql.FriendRequest) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) Notification(com.abewy.android.apps.klyph.core.fql.Notification) KlyphNotification(com.abewy.android.apps.klyph.KlyphNotification)

Example 92 with GraphObject

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

the class Notifications method populate.

@Override
protected void populate(List<GraphObject> data) {
    getAdapter().clear(false);
    List<GraphObject> readNotifications = new ArrayList<GraphObject>();
    List<GraphObject> unreadNotifications = new ArrayList<GraphObject>();
    List<GraphObject> friendRequests = new ArrayList<GraphObject>();
    for (GraphObject graphObject : data) {
        if (graphObject instanceof Notification) {
            if (((Notification) graphObject).getIs_unread() == true) {
                unreadNotifications.add(graphObject);
            } else {
                readNotifications.add(graphObject);
            }
        } else {
            friendRequests.add(graphObject);
        }
    }
    List<GraphObject> list = new ArrayList<GraphObject>();
    unreadCount = unreadNotifications.size();
    if (unreadNotifications.size() > 0) {
        unreadNotifications.get(unreadNotifications.size() - 1).setShowDivider(false);
        Header nTitle = new Header();
        nTitle.setName(getString(R.string.notifications_unread_header_title, unreadNotifications.size()));
        list.add(nTitle);
        list.addAll(unreadNotifications);
    }
    if (readNotifications.size() > 0) {
        readNotifications.get(readNotifications.size() - 1).setShowDivider(false);
        Header nTitle = new Header();
        nTitle.setName(getString(R.string.notifications_read_header_title));
        list.add(nTitle);
        list.addAll(readNotifications);
    }
    if (friendRequests.size() > 0) {
        friendRequests.get(friendRequests.size() - 1).setShowDivider(false);
        Header fTitle = new Header();
        fTitle.setName(getString(R.string.notifications_friend_request_header_title));
        list.add(fTitle);
        list.addAll(friendRequests);
    }
    super.populate(list);
    lastUpdateTime = new Date().getTime();
    setActionBarRefreshItemLoading(false);
    ((NotificationsListener) getActivity()).onNewNotifications();
// getActivity().supportInvalidateOptionsMenu();
/*
		 * if (data.size() > 0)
		 * setOffset(((Notification) data.get(data.size() - 1)).getCreated_time());
		 */
}
Also used : Header(com.abewy.klyph.items.Header) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) Notification(com.abewy.android.apps.klyph.core.fql.Notification) KlyphNotification(com.abewy.android.apps.klyph.KlyphNotification) Date(java.util.Date)

Example 93 with GraphObject

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

the class KlyphFragment method startLoading.

protected void startLoading() {
    loading = true;
    if (isError == true && getAdapter().getCount() > 0) {
        GraphObject lastObject = getAdapter().getLastItem();
        if (lastObject instanceof TextButtonItem) {
            getAdapter().remove(lastObject);
        }
    }
    isError = false;
    if (!firstLoad) {
        if (!loadingObjectAsFirstItem)
            getAdapter().add(loadingObject);
        else
            getAdapter().insert(loadingObject, 0);
        getAdapter().notifyDataSetChanged();
    }
}
Also used : TextButtonItem(com.abewy.klyph.items.TextButtonItem) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 94 with GraphObject

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

the class Search method onGridItemClick.

@Override
public void onGridItemClick(KlyphGridView l, View v, int position, long id) {
    GraphObject graphObject = (GraphObject) l.getItemAtPosition(position);
    startActivity(Klyph.getIntentForGraphObject(getActivity(), graphObject));
}
Also used : GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 95 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)

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