Пример #1
0
  private void loadMarkdown() {
    ViewUtils.setGone(loadingBar, false);
    ViewUtils.setGone(codeView, true);

    String markdown = new String(EncodingUtils.fromBase64(blob.getContent()));
    Bundle args = new Bundle();
    args.putCharSequence(ARG_TEXT, markdown);
    args.putSerializable(ARG_REPO, repo);
    getSupportLoaderManager().restartLoader(0, args, this);
  }
  private void loadMarkdown() {
    ViewUtils.setGone(loadingBar, false);
    ViewUtils.setGone(codeView, true);

    String markdown = new String(Base64.decode(blob.content, Base64.DEFAULT));
    Bundle args = new Bundle();
    args.putCharSequence(ARG_TEXT, markdown);
    args.putParcelable(ARG_REPO, repo);
    getSupportLoaderManager().restartLoader(0, args, this);
  }
  @Override
  public void onLoadFinished(Loader<CharSequence> loader, CharSequence rendered) {
    if (rendered == null) ToastUtils.show(this, R.string.error_rendering_markdown);

    ViewUtils.setGone(loadingBar, true);
    ViewUtils.setGone(codeView, false);

    if (!TextUtils.isEmpty(rendered)) {
      renderedMarkdown = rendered.toString();
      if (markdownItem != null) markdownItem.setEnabled(true);
      editor.setMarkdown(true).setSource(file, renderedMarkdown, false);
    }
  }
    @Override
    protected void update(int position, Milestone item) {
      setText(1, item.getTitle());

      String description = item.getDescription();
      if (!TextUtils.isEmpty(description)) ViewUtils.setGone(setText(2, description), false);
      else setGone(2, true);

      setChecked(0, selected == position);
    }
Пример #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    User owner = repository.getOwner();

    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(repository.getName());
    actionBar.setSubtitle(owner.getLogin());
    actionBar.setDisplayHomeAsUpEnabled(true);

    if (owner.getAvatarUrl() != null && RepositoryUtils.isComplete(repository)) configurePager();
    else {
      avatars.bind(getSupportActionBar(), owner);
      ViewUtils.setGone(loadingBar, false);
      setGone(true);
      new RefreshRepositoryTask(this, repository) {

        @Override
        protected void onSuccess(Repository fullRepository) throws Exception {
          super.onSuccess(fullRepository);

          repository = fullRepository;
          configurePager();
        }

        @Override
        protected void onException(Exception e) throws RuntimeException {
          super.onException(e);

          ToastUtils.show(RepositoryViewActivity.this, string.error_repo_load);
          ViewUtils.setGone(loadingBar, true);
        }
      }.execute();
    }
  }
 private void showLoading(final boolean loading) {
   ViewUtils.setGone(progress, !loading);
   ViewUtils.setGone(bodyText, loading);
 }
Пример #7
0
 private ItemListFragment<E> hide(final View view) {
   ViewUtils.setGone(view, true);
   return this;
 }
Пример #8
0
 private ItemListFragment<E> show(final View view) {
   ViewUtils.setGone(view, false);
   return this;
 }
  private void updateHeader(final Issue issue) {
    if (!isUsable()) return;

    boolean isPullRequest = IssueUtils.isPullRequest(issue);
    titleText.setText(issue.getTitle());

    String body = issue.getBodyHtml();
    if (!TextUtils.isEmpty(body)) bodyImageGetter.bind(bodyText, body, issue.getId());
    else bodyText.setText(R.string.no_description_given);

    authorText.setText(issue.getUser().getLogin());
    createdDateText.setText(
        new StyledText().append(getString(R.string.prefix_opened)).append(issue.getCreatedAt()));
    avatars.bind(creatorAvatar, issue.getUser());

    if (isPullRequest && issue.getPullRequest().getCommits() > 0) {
      ViewUtils.setGone(commitsView, false);

      TextView icon = (TextView) headerView.findViewById(R.id.tv_commit_icon);
      TypefaceUtils.setOcticons(icon);
      icon.setText(TypefaceUtils.ICON_GIT_COMMIT);

      String commits =
          getString(R.string.pull_request_commits, issue.getPullRequest().getCommits());
      ((TextView) headerView.findViewById(R.id.tv_pull_request_commits)).setText(commits);
    } else ViewUtils.setGone(commitsView, true);

    boolean open = STATE_OPEN.equals(issue.getState());
    if (!open) {
      StyledText text = new StyledText();
      if (isPullRequest && issue.getPullRequest().isMerged()) {
        text.bold(getString(R.string.merged));
        stateText.setBackgroundResource(R.color.state_background_merged);
      } else {
        text.bold(getString(R.string.closed));
        stateText.setBackgroundResource(R.color.state_background_closed);
      }
      Date closedAt = issue.getClosedAt();
      if (closedAt != null) text.append(' ').append(closedAt);
      stateText.setText(text);
    }
    ViewUtils.setGone(stateText, open);

    User assignee = issue.getAssignee();
    if (assignee != null) {
      StyledText name = new StyledText();
      name.bold(assignee.getLogin());
      name.append(' ').append(getString(R.string.assigned));
      assigneeText.setText(name);
      assigneeAvatar.setVisibility(VISIBLE);
      avatars.bind(assigneeAvatar, assignee);
    } else {
      assigneeAvatar.setVisibility(GONE);
      assigneeText.setText(R.string.unassigned);
    }

    List<Label> labels = issue.getLabels();
    if (labels != null && !labels.isEmpty()) {
      LabelDrawableSpan.setText(labelsArea, labels);
      labelsArea.setVisibility(VISIBLE);
    } else labelsArea.setVisibility(GONE);

    if (issue.getMilestone() != null) {
      Milestone milestone = issue.getMilestone();
      StyledText milestoneLabel = new StyledText();
      milestoneLabel.append(getString(R.string.milestone_prefix));
      milestoneLabel.append(' ');
      milestoneLabel.bold(milestone.getTitle());
      milestoneText.setText(milestoneLabel);
      float closed = milestone.getClosedIssues();
      float total = closed + milestone.getOpenIssues();
      if (total > 0) {
        ((LayoutParams) milestoneProgressArea.getLayoutParams()).weight = closed / total;
        milestoneProgressArea.setVisibility(VISIBLE);
      } else milestoneProgressArea.setVisibility(GONE);
      milestoneArea.setVisibility(VISIBLE);
    } else milestoneArea.setVisibility(GONE);

    String state = issue.getState();
    if (state != null && state.length() > 0)
      state = state.substring(0, 1).toUpperCase(Locale.US) + state.substring(1);
    else state = "";

    ViewUtils.setGone(progress, true);
    ViewUtils.setGone(list, false);
    updateStateItem(issue);
  }
Пример #10
0
 private void configurePager() {
   avatars.bind(getSupportActionBar(), repository.getOwner());
   configureTabPager();
   ViewUtils.setGone(loadingBar, true);
   setGone(false);
 }