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();
}
}
Aggregations