Search in sources :

Example 6 with Notification

use of com.abewy.android.apps.klyph.core.fql.Notification in project Klyph by jonathangerbaud.

the class NotificationAdapter method mergeViewWithData.

@Override
protected void mergeViewWithData(View view, GraphObject data) {
    super.mergeViewWithData(view, data);
    PicturePrimarySecondaryTextHolder holder = (PicturePrimarySecondaryTextHolder) getHolder(view);
    //holder.getPicture().setImageDrawable(null);
    Notification notification = (Notification) data;
    holder.getPrimaryText().setText(Html.fromHtml(getFormattedHtmlTitle(notification.getTitle_html())));
    holder.getSecondaryText().setText(DateUtil.timeAgoInWords(getContext(view), notification.getUpdated_time()));
    ((ProfileImageView) holder.getPicture()).disableBorder();
    loadImage(holder.getPicture(), notification.getSender_pic(), KlyphUtil.getProfilePlaceHolder(view.getContext()), data);
    holder.getDivider().setVisibility(notification.mustShowDivider() ? View.VISIBLE : View.GONE);
}
Also used : ProfileImageView(com.abewy.android.apps.klyph.widget.ProfileImageView) Notification(com.abewy.android.apps.klyph.core.fql.Notification) PicturePrimarySecondaryTextHolder(com.abewy.android.apps.klyph.adapter.holder.PicturePrimarySecondaryTextHolder)

Example 7 with Notification

use of com.abewy.android.apps.klyph.core.fql.Notification 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 8 with Notification

use of com.abewy.android.apps.klyph.core.fql.Notification 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

Notification (com.abewy.android.apps.klyph.core.fql.Notification)8 KlyphNotification (com.abewy.android.apps.klyph.KlyphNotification)6 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)6 ArrayList (java.util.ArrayList)5 FriendRequest (com.abewy.android.apps.klyph.core.fql.FriendRequest)3 Header (com.abewy.klyph.items.Header)2 Date (java.util.Date)2 List (java.util.List)2 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Handler (android.os.Handler)1 AbsListView (android.widget.AbsListView)1 MultiObjectAdapter (com.abewy.android.apps.klyph.adapter.MultiObjectAdapter)1 PicturePrimarySecondaryTextHolder (com.abewy.android.apps.klyph.adapter.holder.PicturePrimarySecondaryTextHolder)1 AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)1 ProfileImageView (com.abewy.android.apps.klyph.widget.ProfileImageView)1 OnDismissCallback (com.haarman.listviewanimations.itemmanipulation.OnDismissCallback)1