Search in sources :

Example 1 with NotificationItem

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

Example 2 with NotificationItem

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);
        }
    }
}
Also used : NotificationItem(com.github.pockethub.android.ui.item.notification.NotificationItem) NotificationThread(com.meisolsson.githubsdk.model.NotificationThread) Issue(com.meisolsson.githubsdk.model.Issue) Intent(android.content.Intent)

Aggregations

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