protected void updateComment(final GithubComment comment) {
    imageGetter.bind(textView(0), comment.body, comment.id);
    avatars.bind(imageView(3), comment.user);

    setText(1, comment.user.login);
    setText(2, TimeUtils.getRelativeTime(comment.updated_at));

    final boolean canEdit =
        (canWrite || comment.user.login.equals(userName)) && editCommentListener != null;

    final boolean canDelete =
        (canWrite || comment.user.login.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
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_pager);

    setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(R.id.toolbar));

    pager = finder.find(R.id.vp_pages);

    repository = getIntent().getParcelableExtra(EXTRA_REPOSITORY);
    ids = getCharSequenceArrayExtra(EXTRA_BASES);
    initialPosition = getIntExtra(EXTRA_POSITION);

    adapter = new CommitPagerAdapter(this, repository, ids);
    pager.setAdapter(adapter);
    pager.setOnPageChangeListener(this);
    pager.scheduleSetItem(initialPosition, this);
    onPageSelected(initialPosition);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setSubtitle(InfoUtils.createRepoId(repository));
    avatars.bind(actionBar, repository.owner());
  }
  protected void updateEvent(final IssueEvent event) {
    TypefaceUtils.setOcticons(textView(0));
    String message = String.format("<b>%s</b> %s", event.actor.login, event.event);
    avatars.bind(imageView(2), event.actor);

    String eventString = event.event;

    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.commit_id.substring(0, 6),
                issue.pullRequest.base.ref,
                issue.pullRequest.head.ref);
        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.created_at);
    setText(1, Html.fromHtml(message));
  }