@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle args = getArguments();
    repositoryId =
        RepositoryId.create(
            args.getString(EXTRA_REPOSITORY_OWNER), args.getString(EXTRA_REPOSITORY_NAME));
    issueNumber = args.getInt(EXTRA_ISSUE_NUMBER);
    user = (User) args.getSerializable(EXTRA_USER);
    isCollaborator = args.getBoolean(EXTRA_IS_COLLABORATOR, false);

    DialogFragmentActivity dialogActivity = (DialogFragmentActivity) getActivity();

    milestoneTask =
        new EditMilestoneTask(dialogActivity, repositoryId, issueNumber) {

          @Override
          protected void onSuccess(Issue editedIssue) throws Exception {
            super.onSuccess(editedIssue);

            updateHeader(editedIssue);
          }
        };

    assigneeTask =
        new EditAssigneeTask(dialogActivity, repositoryId, issueNumber) {

          @Override
          protected void onSuccess(Issue editedIssue) throws Exception {
            super.onSuccess(editedIssue);

            updateHeader(editedIssue);
          }
        };

    labelsTask =
        new EditLabelsTask(dialogActivity, repositoryId, issueNumber) {

          @Override
          protected void onSuccess(Issue editedIssue) throws Exception {
            super.onSuccess(editedIssue);

            updateHeader(editedIssue);
          }
        };

    stateTask =
        new EditStateTask(dialogActivity, repositoryId, issueNumber) {

          @Override
          protected void onSuccess(Issue editedIssue) throws Exception {
            super.onSuccess(editedIssue);

            updateHeader(editedIssue);
          }
        };
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    adapter.addHeader(headerView);
    adapter.addFooter(footerView);

    issue = store.getIssue(repositoryId, issueNumber);

    TextView loadingText = (TextView) loadingView.findViewById(R.id.tv_loading);
    loadingText.setText(R.string.loading_comments);

    if (issue == null || (issue.getComments() > 0 && items == null)) adapter.addHeader(loadingView);

    if (issue != null && items != null) updateList(issue, items);
    else {
      if (issue != null) updateHeader(issue);
      refreshIssue();
    }
  }
  @Override
  public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    updateStateItem(issue);
  }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    list = finder.find(android.R.id.list);
    progress = finder.find(R.id.pb_loading);

    LayoutInflater inflater = getLayoutInflater(savedInstanceState);

    headerView = inflater.inflate(R.layout.issue_header, null);

    stateText = (TextView) headerView.findViewById(R.id.tv_state);
    titleText = (TextView) headerView.findViewById(R.id.tv_issue_title);
    authorText = (TextView) headerView.findViewById(R.id.tv_issue_author);
    createdDateText = (TextView) headerView.findViewById(R.id.tv_issue_creation_date);
    creatorAvatar = (ImageView) headerView.findViewById(R.id.iv_avatar);
    commitsView = (ViewGroup) headerView.findViewById(R.id.ll_issue_commits);
    assigneeText = (TextView) headerView.findViewById(R.id.tv_assignee_name);
    assigneeAvatar = (ImageView) headerView.findViewById(R.id.iv_assignee_avatar);
    labelsArea = (TextView) headerView.findViewById(R.id.tv_labels);
    milestoneArea = headerView.findViewById(R.id.ll_milestone);
    milestoneText = (TextView) headerView.findViewById(R.id.tv_milestone);
    milestoneProgressArea = headerView.findViewById(R.id.v_closed);
    bodyText = (TextView) headerView.findViewById(R.id.tv_issue_body);
    bodyText.setMovementMethod(LinkMovementMethod.getInstance());

    loadingView = inflater.inflate(R.layout.loading_item, null);

    footerView = inflater.inflate(R.layout.footer_separator, null);

    commitsView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (IssueUtils.isPullRequest(issue)) openPullRequestCommits();
          }
        });

    stateText.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (issue != null) stateTask.confirm(STATE_OPEN.equals(issue.getState()));
          }
        });

    milestoneArea.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (issue != null && isCollaborator) milestoneTask.prompt(issue.getMilestone());
          }
        });

    headerView
        .findViewById(R.id.ll_assignee)
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                if (issue != null && isCollaborator) assigneeTask.prompt(issue.getAssignee());
              }
            });

    labelsArea.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (issue != null && isCollaborator) labelsTask.prompt(issue.getLabels());
          }
        });

    Activity activity = getActivity();
    loggedUser = AccountUtils.getLogin(activity);
    adapter =
        new HeaderFooterListAdapter<CommentListAdapter>(
            list,
            new CommentListAdapter(
                activity, avatars, commentImageGetter, this, isCollaborator, loggedUser));
    list.setAdapter(adapter);
  }