Search in sources :

Example 1 with OnDismissCallback

use of com.haarman.listviewanimations.itemmanipulation.OnDismissCallback 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)

Aggregations

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