示例#1
0
  protected void updateComment(final Comment comment) {
    imageGetter.bind(textView(0), comment.getBodyHtml(), comment.getId());
    avatars.bind(imageView(3), comment.getUser());

    setText(1, comment.getUser().getLogin());
    setText(2, TimeUtils.getRelativeTime(comment.getUpdatedAt()));

    final boolean canEdit =
        (isOwner || comment.getUser().getLogin().equals(userName)) && editCommentListener != null;

    final boolean canDelete =
        (isOwner || comment.getUser().getLogin().equals(userName)) && deleteCommentListener != null;

    final ImageView ivMore = view(4);

    if (!canEdit && !canDelete) ivMore.setVisibility(View.INVISIBLE);
    else
      ivMore.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              showMorePopup(ivMore, comment, canEdit, canDelete);
            }
          });
  }
示例#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));
  }