Search in sources :

Example 1 with NotificationHeaderItem

use of com.github.pockethub.android.ui.item.notification.NotificationHeaderItem in project PocketHub by pockethub.

the class NotificationListFragment method updateHeaders.

private void updateHeaders(final List<Item> notifications) {
    if (notifications.isEmpty()) {
        return;
    }
    Collections.sort(notifications, (i1, i2) -> {
        Repository r1 = ((NotificationItem) i1).getNotificationThread().repository();
        Repository r2 = ((NotificationItem) i2).getNotificationThread().repository();
        return r1.fullName().compareToIgnoreCase(r2.fullName());
    });
    Repository repoFound = null;
    for (int i = 0; i < notifications.size(); i++) {
        NotificationItem item = (NotificationItem) notifications.get(i);
        NotificationThread thread = item.getNotificationThread();
        String fullName = thread.repository().fullName();
        if (repoFound == null || !fullName.equals(repoFound.fullName())) {
            notifications.add(i, new NotificationHeaderItem(thread.repository(), this));
        }
        repoFound = thread.repository();
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) NotificationItem(com.github.pockethub.android.ui.item.notification.NotificationItem) NotificationThread(com.meisolsson.githubsdk.model.NotificationThread) NotificationHeaderItem(com.github.pockethub.android.ui.item.notification.NotificationHeaderItem)

Aggregations

NotificationHeaderItem (com.github.pockethub.android.ui.item.notification.NotificationHeaderItem)1 NotificationItem (com.github.pockethub.android.ui.item.notification.NotificationItem)1 NotificationThread (com.meisolsson.githubsdk.model.NotificationThread)1 Repository (com.meisolsson.githubsdk.model.Repository)1