Search in sources :

Example 1 with Header

use of com.abewy.klyph.items.Header in project Klyph by jonathangerbaud.

the class Notifications method onActivityCreated.

/*
	 * @Override
	 * protected KlyphPullToRefreshListView onCreatePullToRefreshListView(LayoutInflater inflater, Bundle savedInstanceState)
	 * {
	 * return (KlyphPullToRefreshListView) inflater.inflate(R.layout.list_notifications, null);
	 * }
	 */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    NotificationSwipeDismissAdapter swAdapter = new NotificationSwipeDismissAdapter(new MultiObjectAdapter(getListView()), new OnDismissCallback() {

        @Override
        public void onDismiss(AbsListView arg0, int[] positions) {
            for (int i : positions) {
                if (getAdapter().getItem(i) instanceof Notification) {
                    Notification notification = (Notification) getAdapter().getItem(i);
                    setNotificationRead(notification);
                }
            }
            List<GraphObject> list = new ArrayList<GraphObject>();
            for (GraphObject o : getAdapter().getItems()) {
                if (!(o instanceof Header)) {
                    list.add(o);
                }
            }
            populate(list);
        }
    });
    swAdapter.setAbsListView(getListView());
    setListAdapter(swAdapter);
    // setListAdapter(new MultiObjectAdapter(getListView()));
    defineEmptyText(R.string.empty_list_no_notification);
    setListVisible(false);
    setRequestType(Query.NOTIFICATIONS);
    loggedIn = true;
    new Handler().postDelayed(new Runnable() {

        public void run() {
            loadNotifications();
        }
    }, 2000);
}
Also used : MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) OnDismissCallback(com.haarman.listviewanimations.itemmanipulation.OnDismissCallback) AbsListView(android.widget.AbsListView) Handler(android.os.Handler) 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) Header(com.abewy.klyph.items.Header) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with Header

use of com.abewy.klyph.items.Header in project Klyph by jonathangerbaud.

the class HeaderAdapter method mergeViewWithData.

@Override
protected void mergeViewWithData(View view, GraphObject data) {
    Header header = (Header) data;
    HeaderHolder holder = (HeaderHolder) view.getTag();
    holder.getHeaderTitle().setText(header.getName());
}
Also used : HeaderHolder(com.abewy.android.apps.klyph.adapter.holder.HeaderHolder) Header(com.abewy.klyph.items.Header)

Example 3 with Header

use of com.abewy.klyph.items.Header 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)

Aggregations

Header (com.abewy.klyph.items.Header)3 KlyphNotification (com.abewy.android.apps.klyph.KlyphNotification)2 Notification (com.abewy.android.apps.klyph.core.fql.Notification)2 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)2 ArrayList (java.util.ArrayList)2 Handler (android.os.Handler)1 AbsListView (android.widget.AbsListView)1 MultiObjectAdapter (com.abewy.android.apps.klyph.adapter.MultiObjectAdapter)1 HeaderHolder (com.abewy.android.apps.klyph.adapter.holder.HeaderHolder)1 OnDismissCallback (com.haarman.listviewanimations.itemmanipulation.OnDismissCallback)1 Date (java.util.Date)1 List (java.util.List)1