use of com.github.pockethub.android.ui.item.notification.NotificationItem 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();
}
}
use of com.github.pockethub.android.ui.item.notification.NotificationItem in project PocketHub by pockethub.
the class NotificationListFragment method onItemClick.
@Override
public void onItemClick(@NonNull Item item, @NonNull View view) {
if (item instanceof NotificationItem) {
NotificationThread thread = ((NotificationItem) item).getNotificationThread();
String url = thread.subject().url();
Issue issue = IssueUriMatcher.getApiIssue(url);
if (issue != null) {
Intent intent = IssuesViewActivity.createIntent(issue, thread.repository());
startActivity(intent);
} else {
ToastUtils.show(getActivity(), R.string.releases_not_yet_in_app);
}
}
}
Aggregations