private static boolean shouldAddEvent(IssueEvent event, List<Object> allItems) {
    // Exclude some events
    List<String> excludedEvents =
        Arrays.asList(IssueEvent.TYPE_MENTIONED, IssueEvent.TYPE_SUBSCRIBED);
    if (excludedEvents.contains(event.getEvent())) return false;

    // Don't show references to nonexistent commits
    if (IssueEvent.TYPE_REFERENCED.equals(event.getEvent()) && event.getCommitId() == null)
      return false;

    // Don't show the close event after the merged event
    if (!IssueEvent.TYPE_CLOSED.equals(event.getEvent())) return true;

    int currentSize = allItems.size();
    if (currentSize == 0) return true;

    Object previousItem = allItems.get(currentSize - 1);
    if (!(previousItem instanceof IssueEvent)) return true;

    if (IssueEvent.TYPE_MERGED.equals(((IssueEvent) previousItem).getEvent())) return false;

    return true;
  }
Пример #2
0
  protected void updateEvent(final IssueEvent event) {
    TypefaceUtils.setOcticons(textView(0));
    String message = String.format("<b>%s</b> %s", event.getActor().getLogin(), event.getEvent());
    avatars.bind(imageView(2), event.getActor());

    String eventString = event.getEvent();

    switch (eventString) {
      case "assigned":
      case "unassigned":
        setText(0, TypefaceUtils.ICON_PERSON);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "labeled":
      case "unlabeled":
        setText(0, TypefaceUtils.ICON_TAG);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "referenced":
        setText(0, TypefaceUtils.ICON_BOOKMARK);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "milestoned":
      case "demilestoned":
        setText(0, TypefaceUtils.ICON_MILESTONE);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "closed":
        setText(0, TypefaceUtils.ICON_ISSUE_CLOSE);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_closed));
        break;
      case "reopened":
        setText(0, TypefaceUtils.ICON_ISSUE_REOPEN);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_reopened));
        break;
      case "renamed":
        setText(0, TypefaceUtils.ICON_EDIT);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "merged":
        message +=
            String.format(
                " commit <b>%s</b> into <tt>%s</tt> from <tt>%s</tt>",
                event.getCommitId().substring(0, 6),
                issue.getPullRequest().getBase().getRef(),
                issue.getPullRequest().getHead().getRef());
        setText(0, TypefaceUtils.ICON_MERGE);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_merged));
        break;
      case "locked":
        setText(0, TypefaceUtils.ICON_LOCK);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_lock));
        break;
      case "unlocked":
        setText(0, TypefaceUtils.ICON_KEY);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_lock));
        break;
    }

    message += " " + TimeUtils.getRelativeTime(event.getCreatedAt());
    setText(1, Html.fromHtml(message));
  }