private void prepareData(GitData gitData, List<Repository> repositories, User user)
      throws IOException {
    UserDetail userDetail = new UserDetail();
    userDetail.setName(user.getLogin());
    userDetail.setAvatarUrl(user.getAvatarUrl());
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yyyy");
    userDetail.setCreatedAt(simpleDateFormat.format(user.getCreatedAt()));
    userDetail.setEmail(user.getEmail());
    userDetail.setFollower(user.getFollowers());
    userDetail.setDiskUsage(user.getDiskUsage());

    gitData.setUser(userDetail);

    Map<String, Integer> usedLanguages = new HashMap<>();
    for (Repository repository : repositories) {
      String language = (repository.getLanguage() == null) ? "Unknown" : repository.getLanguage();
      if (usedLanguages.containsKey(language)) {
        int count = usedLanguages.get(language);
        usedLanguages.replace(language, ++count);
      } else {
        usedLanguages.put(language, 1);
      }
    }

    gitData.setUsedLanguages(usedLanguages);
  }
    private Map<Repository, List<RepositoryBranch>> getHeadRepositories(
        GitHubRepository repository, List<RepositoryBranch> baseBranches) {
      Map<Repository, List<RepositoryBranch>> myRepositories = new HashMap<>();
      GitHubCache cache = GitHubCache.create(repository);
      final User mySelf = cache.getMySelf();
      String repositoryAuthor = repository.getRepositoryAuthor();
      if (repositoryAuthor.equals(mySelf.getLogin())) {
        myRepositories.put(repository.getRepository(), baseBranches);
      } else {
        if (repository.isCollaborator()) {
          myRepositories.put(repository.getRepository(), baseBranches);
        }
        List<Repository> forks = cache.getForks();
        Repository myRepository = null;
        for (Repository fork : forks) {
          User owner = fork.getOwner();
          if (owner.getLogin().equals(mySelf.getLogin())) {
            myRepository = fork;
            break;
          }
        }
        if (myRepository == null) {
          return Collections.emptyMap();
        }

        // get my branches
        GitHubClient client = repository.createGitHubClient();
        List<RepositoryBranch> myRepositoryBranches = getMyRepositoryBranches(client, myRepository);
        myRepositories.put(myRepository, myRepositoryBranches);
      }
      return myRepositories;
    }
 @Override
 protected Loader<LoaderResult<Map<String, String>>> onCreateLoader() {
   return new GitModuleParserLoader(
       getActivity(),
       mRepository.getOwner().getLogin(),
       mRepository.getName(),
       ".gitmodules",
       mSelectedRef);
 }
  @RequestMapping("/output")
  public String func(HttpServletRequest req, HttpServletResponse resp) throws Exception {
    String outputURL = "first";

    try {
      String path = req.getParameter("path");
      // System.out.println(path);
      String arr[] = path.split("/");
      String repoName = arr[arr.length - 1];
      String user = arr[arr.length - 2];
      // System.out.println(user+" - " +path);

      Set<Issue> lessSeven = new LinkedHashSet<Issue>();
      Set<Issue> between24and7 = new LinkedHashSet<Issue>();
      Set<Issue> greaterSeven = new LinkedHashSet<Issue>();

      Date yesterday = new Date(System.currentTimeMillis() - (24 * 60 * 60 * 1000));
      // String yesterdayDate=sdf.format(yesterday);
      Date DaysAgo7Date = new Date(System.currentTimeMillis() - 7 * 24 * 60 * 60 * 1000);
      // String DaysAgo7=sdf.format(DaysAgo7Date);

      GitHubClient git = new GitHubClient();
      // git.setOAuth2Token("39de076299133c5c995ee00b1573f9826887e5bd");
      git.setCredentials("TheMask", "sugandh4");
      RepositoryService repoService = new RepositoryService(git);
      IssueService issueService = new IssueService(git);
      Repository repo = null;
      repo = repoService.getRepository(user, repoName);

      System.out.println(repo.getName());
      System.out.println(repo.getOpenIssues());
      Map<String, String> paramIssue = new HashMap<String, String>();
      paramIssue.put("state", "open");
      // paramIssue.put("sort", "created");
      List<Issue> issueList = issueService.getIssues(repo, paramIssue);
      for (Issue issue : issueList) {
        // System.out.println(issue.getCreatedAt());
        if (issue.getCreatedAt().after(yesterday)) lessSeven.add(issue);
        else if ((issue.getCreatedAt().before(yesterday))
            && (issue.getCreatedAt().after(DaysAgo7Date))) between24and7.add(issue);
        else greaterSeven.add(issue);
      }

      HttpSession session = req.getSession();
      session.setAttribute("firstList", lessSeven);
      session.setAttribute("secondList", between24and7);
      session.setAttribute("thirdList", greaterSeven);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      outputURL = "error";
    }

    System.out.println(outputURL);
    return outputURL;
  }
示例#5
0
  public static boolean repositoryExists(
      RepositoryService repositoryService, RepositoryId repositoryId) throws IOException {
    List<Repository> repositories = repositoryService.getRepositories(repositoryId.getOwner());

    for (Repository repository : repositories) {
      if (repository.generateId().equals(repositoryId.generateId())) {
        return true;
      }
    }

    return false;
  }
 /**
  * Create pull request task repository
  *
  * @param repo
  * @param username
  * @param password
  * @return task repository
  */
 public static TaskRepository createTaskRepository(
     Repository repo, String username, String password) {
   String url =
       PullRequestConnector.appendPulls(
           GitHub.createGitHubUrl(repo.getOwner().getLogin(), repo.getName()));
   TaskRepository repository = new TaskRepository(KIND, url);
   repository.setProperty(IRepositoryConstants.PROPERTY_LABEL, getRepositoryLabel(repo));
   if (username != null && password != null)
     repository.setCredentials(
         AuthenticationType.REPOSITORY, new AuthenticationCredentials(username, password), true);
   repository.setProperty(
       IRepositoryConstants.PROPERTY_CATEGORY, IRepositoryConstants.CATEGORY_REVIEW);
   return repository;
 }
 private void shareFile() {
   String id = repo.generateId();
   startActivity(
       ShareUtils.create(
           path + " at " + CommitUtils.abbreviate(commit) + " on " + id,
           "https://github.com/" + id + "/blob/" + commit + '/' + path));
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.commit_file_view);

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

    repo = getSerializableExtra(EXTRA_REPOSITORY);
    commit = getStringExtra(EXTRA_HEAD);
    sha = getStringExtra(EXTRA_BASE);
    path = getStringExtra(EXTRA_PATH);

    loadingBar = finder.find(R.id.pb_loading);
    codeView = finder.find(R.id.wv_code);

    file = CommitUtils.getName(path);
    isMarkdownFile = MarkdownUtils.isMarkdown(file);

    editor = new SourceEditor(codeView);
    editor.setWrap(PreferenceUtils.getCodePreferences(this).getBoolean(WRAP, false));

    ActionBar actionBar = getSupportActionBar();
    int lastSlash = path.lastIndexOf('/');
    if (lastSlash != -1) actionBar.setTitle(path.substring(lastSlash + 1));
    else actionBar.setTitle(path);
    actionBar.setSubtitle(getString(R.string.commit_prefix) + CommitUtils.abbreviate(commit));
    avatars.bind(actionBar, repo.getOwner());

    loadContent();
  }
示例#9
0
 @Override
 protected boolean viewUser(User user) {
   if (repo.getOwner().getId() != user.getId()) {
     startActivity(UserViewActivity.createIntent(user));
     return true;
   }
   return false;
 }
 /** Test fork event that has an incomplete forkee in the payload */
 public void testIncompleteRepositoryFork() {
   RepositoryEventMatcher matcher = new RepositoryEventMatcher();
   Event event = new Event();
   event.setType(Event.TYPE_FORK);
   ForkPayload payload = new ForkPayload();
   event.setPayload(payload);
   assertNull(matcher.getRepository(event));
   Repository repository = new Repository();
   payload.setForkee(repository);
   assertNull(matcher.getRepository(event));
   repository.setName("repo");
   assertNull(matcher.getRepository(event));
   repository.setOwner(new User());
   assertNull(matcher.getRepository(event));
   repository.getOwner().setLogin("owner");
   assertEquals(repository, matcher.getRepository(event));
 }
 @Override
 public String getCacheName() {
   return CacheUtils.DIR.CODE_TREE
       + repository.getName()
       + "#"
       + curBranch
       + "#"
       + CacheUtils.NAME.CODE_TREE;
 }
  /**
   * Show informational dialog for when a pull request cannot be resolved to a Git repository.
   *
   * @param request must be non-null
   */
  public static void showNoRepositoryDialog(PullRequest request) {
    Repository remoteRepo = request.getBase().getRepo();
    String id = remoteRepo.getOwner().getLogin() + '/' + remoteRepo.getName();
    final String message =
        MessageFormat.format(Messages.PullRequestConnectorUi_MessageRepositoryNotFound, id);
    PlatformUI.getWorkbench()
        .getDisplay()
        .syncExec(
            new Runnable() {

              public void run() {
                MessageDialog.openInformation(
                    PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                    Messages.PullRequestConnectorUi_TitleRepositoryNotFound,
                    message);
              }
            });
  }
示例#13
0
  @Override
  void removeRemoteDvcsRepository() {
    // This method is executed in @AfterClass context by super class and we do not want to break
    // further logic
    // if the service is null (e.g. login failed in Github due to network issue)
    if (githubRepositoriesREST != null) {
      githubRepositoriesREST.removeExistingRepository(
          getMissingCommitsRepositoryName(), DVCS_REPO_OWNER);

      // remove expired repositories
      try {
        for (Repository repository : githubRepositoriesREST.getRepositories(DVCS_REPO_OWNER)) {
          if (timestampNameTestResource.isExpired(repository.getName())) {
            githubRepositoriesREST.removeExistingRepository(repository.getName(), DVCS_REPO_OWNER);
          }
        }
      } catch (IOException e) {
        log.warn("removeRemoteDvcsRepository() failed", e);
      }
    }
  }
 private void compare() {
   Repository headRepo = panel.getSelectedHeadRepository();
   final User owner = headRepo.getOwner();
   BaseProgressUtils.runOffEventDispatchThread(
       new Runnable() {
         @Override
         public void run() {
           try {
             compare =
                 repository.compare(
                     panel.getSelectedBaseBranch().getName(),
                     owner.getLogin() + ":" + panel.getSelectedHeadBranch().getName());
           } catch (IOException ex) {
             errorMessage = ex.getMessage();
           }
         }
       },
       "Comparing...",
       new AtomicBoolean(),
       false); // NOI18N
 }
 @Override
 public void onTreeSelected(RepositoryContents content) {
   String path = content.getPath();
   if (RepositoryContents.TYPE_DIR.equals(content.getType())) {
     mDirStack.push(path);
     updateBreadcrumbs();
     addFragmentForTopOfStack();
   } else if (mGitModuleMap != null && mGitModuleMap.get(path) != null) {
     String[] userRepo = mGitModuleMap.get(path).split("/");
     startActivity(
         IntentUtils.getRepoActivityIntent(getActivity(), userRepo[0], userRepo[1], null));
   } else {
     startActivity(
         IntentUtils.getFileViewerActivityIntent(
             getActivity(),
             mRepository.getOwner().getLogin(),
             mRepository.getName(),
             getCurrentRef(),
             content.getPath()));
   }
 }
  @JavaScriptMethod
  public String checkFork(String fork, String repo) {

    doFillForkItems(fork, repo);

    if (fork.length() == 0) {
      return Messages.Fork_NoFork();
    }

    // check if given fork owner is in fork list
    for (String f : this.forkItems) {
      if (f.equals(fork)) {
        return "__succeeded";
      }
    }

    // if fork owner was not in list
    try {
      // check if user exists
      try {
        UserService githubUserSrv = new UserService(this.githubClient);
        githubUserSrv.getUser(fork);
      } catch (Exception ex) {
        return Messages.Fork_OwnerNotFound() + "\n" + ex.getMessage();
      }
      // check if user has public repository with given name
      try {
        RepositoryService githubRepoSrv = new RepositoryService(this.githubClient);
        List<org.eclipse.egit.github.core.Repository> repos = githubRepoSrv.getRepositories(fork);
        for (org.eclipse.egit.github.core.Repository r : repos) {
          if (r.getName().equals(repo)) return Messages.Fork_Found() + "__succeeded";
        }
      } catch (Exception ex) {
        return Messages.Fork_GetReposFailed() + "\n" + ex.getMessage();
      }
      return "__succeeded";
    } catch (Exception ex) {
      return Messages.Fork_AuthFailed() + "\n" + ex.getMessage();
    }
  }
  /** Checks if given fork owner exists */
  public FormValidation checkDepFork(@QueryParameter String value, @QueryParameter String name)
      throws IOException, ServletException {

    doFillForkItems(value, name);

    if (value.length() == 0) {
      return FormValidation.error(Messages.Fork_NoFork());
    }

    // check if given fork owner is in fork list
    /*for (String fork : this.forkItems) {
    	if (fork.equals(value)) {
    		return (msg.length()==0) ? FormValidation.ok() : FormValidation.ok(msg);
    	}
    }*/

    // if fork owner was not in list
    try {
      // check if user exists
      try {
        UserService githubUserSrv = new UserService(this.githubClient);
        githubUserSrv.getUser(value);
      } catch (Exception ex) {
        return FormValidation.error(Messages.Fork_OwnerNotFound() + "\n" + ex.getMessage());
      }
      // check if user has public repository with given name
      try {
        RepositoryService githubRepoSrv = new RepositoryService(this.githubClient);
        List<org.eclipse.egit.github.core.Repository> repos = githubRepoSrv.getRepositories(value);
        for (org.eclipse.egit.github.core.Repository repo : repos) {
          if (repo.getName().equals(name)) return FormValidation.ok(Messages.Fork_Found());
        }
      } catch (Exception ex) {
        return FormValidation.error(Messages.Fork_GetReposFailed() + "\n" + ex.getMessage());
      }
      return FormValidation.ok();
    } catch (Exception ex) {
      return FormValidation.error(Messages.Fork_AuthFailed() + "\n" + ex.getMessage());
    }
  }
示例#18
0
  private void updateHeaders(final List<Repository> repos) {
    HeaderFooterListAdapter<?> rootAdapter = getListAdapter();
    if (rootAdapter == null) return;

    DefaultRepositoryListAdapter adapter =
        (DefaultRepositoryListAdapter) rootAdapter.getWrappedAdapter();
    adapter.clearHeaders();

    char start = 'a';
    Repository previous = null;
    for (int i = 0; i < repos.size(); i++) {
      Repository repository = repos.get(i);

      if (recentRepos.contains(repository.getId())) {
        previous = repository;
        continue;
      }

      char repoStart = Character.toLowerCase(repository.getName().charAt(0));
      if (repoStart < start) {
        previous = repository;
        continue;
      }

      adapter.registerHeader(repository, Character.toString(repoStart).toUpperCase(US));
      if (previous != null) adapter.registerNoSeparator(previous);
      start = repoStart;
      if (start == 'z') break;
      start++;
      previous = repository;
    }

    if (!repos.isEmpty()) {
      Repository first = repos.get(0);
      if (recentRepos.contains(first))
        adapter.registerHeader(first, getString(string.recently_viewed));
    }
  }
  /** Fills combobox with repository names of organization */
  public ComboBoxModel doFillNameItems(@QueryParameter String fork) {
    ComboBoxModel aux = new ComboBoxModel();

    if (this.githubClient.getUser() == null) {
      setGithubConfig();
    }

    if (fork.length() == 0) {
      return aux;
    }

    try {
      RepositoryService githubRepoSrv = new RepositoryService(githubClient);
      List<org.eclipse.egit.github.core.Repository> repos = githubRepoSrv.getRepositories(fork);
      for (org.eclipse.egit.github.core.Repository repo : repos) {
        if (!aux.contains(repo.getName())) aux.add(0, repo.getName());
      }
    } catch (IOException ex) {
      // TODO: handle exception
    }
    Collections.sort(aux);
    return this.repoNameItems = aux;
  }
  /** Checks if given repository exists */
  public FormValidation checkDepName(@QueryParameter String value, @QueryParameter String fork)
      throws IOException, ServletException {

    doFillNameItems(fork);

    if (fork.length() == 0) {
      return FormValidation.error(Messages.Dependency_NoFork());
    }

    if (value.length() == 0) {
      return FormValidation.warning(Messages.Repository_NoName());
    }

    // check if given repository is in repo list
    for (String repoName : this.repoNameItems) {
      if (repoName.equals(value)) {
        return FormValidation.ok();
      }
    }
    // if repository was not in list, for example extern repository
    try {
      RepositoryService githubRepoSrv = new RepositoryService(githubClient);
      org.eclipse.egit.github.core.Repository selectedRepo =
          githubRepoSrv.getRepository(fork, value);
      if (selectedRepo != null) {
        if (selectedRepo.isPrivate()) {
          return FormValidation.ok(Messages.Dependency_PrivateFound());
        }
        return FormValidation.ok();
      }
    } catch (IOException ex) {
      // TODO: handle exception
    }

    return FormValidation.warning(
        Messages.Dependency_NotFound(value, fork)); // error(Messages.Repository_NoFound());
  }
  @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();
    }
  }
  @JavaScriptMethod
  public String checkName(String repo, String fork) {

    doFillNameItems(fork);

    if (fork.length() == 0) {
      return Messages.Repository_NoFork();
    }

    if (repo.length() == 0) {
      return Messages.Repository_NoName();
    }

    // check if given repository is in repo list
    for (String repoName : this.repoNameItems) {
      if (repoName.equals(repo)) {
        return "";
      }
    }
    // if repository was not in list, for example extern repository
    try {
      RepositoryService githubRepoSrv = new RepositoryService(githubClient);
      org.eclipse.egit.github.core.Repository selectedRepo =
          githubRepoSrv.getRepository(fork, repo);
      if (selectedRepo != null) {
        if (selectedRepo.isPrivate()) {
          return Messages.Repository_PrivateFound() + "__succeeded";
        }
        return "__succeeded";
      }
    } catch (IOException ex) {
      // TODO: handle exception
    }

    return Messages.Repository_NotFound(repo, fork);
  }
  /** Fill combobox with forks of repository */
  public ComboBoxModel doFillForkItems(@QueryParameter String value, @QueryParameter String name) {
    ComboBoxModel aux = new ComboBoxModel();

    if (this.githubClient.getUser() == null) {
      setGithubConfig();
    }

    try {
      RepositoryService githubRepoSrv = new RepositoryService(this.githubClient);
      List<org.eclipse.egit.github.core.Repository> forks;

      try {
        // get parent repository if repository itself is forked
        org.eclipse.egit.github.core.Repository parent =
            githubRepoSrv.getRepository(value, name).getParent();

        if (parent != null) {
          // get fork of parent repository
          forks = githubRepoSrv.getForks(parent);
          for (org.eclipse.egit.github.core.Repository fork : forks) {
            org.eclipse.egit.github.core.User user = fork.getOwner();
            aux.add(user.getLogin());
          }
        }

        if (aux.isEmpty()) {
          // add forks of repository
          forks = githubRepoSrv.getForks(new RepositoryId(value, name));
          for (org.eclipse.egit.github.core.Repository fork : forks) {
            org.eclipse.egit.github.core.User user = fork.getOwner();
            aux.add(user.getLogin());
          }
        }
        aux.add(0, value);
      } catch (Exception ex) {
      }

      try {
        // try to use global githubLogin, find repository and add forks
        forks = githubRepoSrv.getForks(new RepositoryId(this.githubLogin, name));
        for (org.eclipse.egit.github.core.Repository fork : forks) {
          org.eclipse.egit.github.core.User user = fork.getOwner();
          if (!aux.contains(user.getLogin())) {
            aux.add(user.getLogin());
          }
        }
      } catch (Exception ex) {
      }

    } catch (Exception ex) {
      // TODO: handle exception
    }
    Collections.sort(aux);
    return this.forkItems = aux;
  }
示例#24
0
 @Override
 public boolean setMenuOptionItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       getApplicationContext()
           .openUserInfoActivity(this, mRepoOwner, null, Intent.FLAG_ACTIVITY_CLEAR_TOP);
       return true;
     case R.id.watch:
       item.setActionView(R.layout.ab_loading);
       item.expandActionView();
       getSupportLoaderManager().restartLoader(4, null, this);
       getSupportLoaderManager().getLoader(4).forceLoad();
       return true;
     case R.id.branches:
       if (mBranches == null) {
         mProgressDialog = showProgressDialog(getString(R.string.loading_msg), true);
         getSupportLoaderManager().getLoader(1).forceLoad();
       } else {
         showBranchesDialog();
       }
       return true;
     case R.id.tags:
       if (mTags == null) {
         mProgressDialog = showProgressDialog(getString(R.string.loading_msg), true);
         getSupportLoaderManager().getLoader(2).forceLoad();
       } else {
         showTagsDialog();
       }
       return true;
     case R.id.refresh:
       item.setActionView(R.layout.ab_loading);
       item.expandActionView();
       refreshFragment();
       return true;
     case R.id.share:
       Intent shareIntent = new Intent(Intent.ACTION_SEND);
       shareIntent.setType("text/plain");
       shareIntent.putExtra(Intent.EXTRA_SUBJECT, mRepoOwner + "/" + mRepoName);
       shareIntent.putExtra(
           Intent.EXTRA_TEXT, mRepoOwner + "/" + mRepoName + " " + mRepository.getHtmlUrl());
       shareIntent = Intent.createChooser(shareIntent, "Share");
       startActivity(shareIntent);
       return true;
     default:
       return true;
   }
 }
  @Override
  protected void initData() {
    repository = (Repository) context.getIntent().getSerializableExtra(Constants.Extra.REPOSITORY);

    curBranch = repository.getMasterBranch();

    setLoadCache(CacheUtils.contain(getCacheName()));

    if (currCodeTree == null) execute();
    else {
      ViewUtils.setVisibility(listPopup, View.VISIBLE, R.anim.alpha_in);
      branch.setText(curBranch);
      codeAdapter.setCodeTree(currCodeTree);
      if (!currCodeTree.name.equals(CodeTree.ROOT))
        pathView.resetView(currCodeTree.currEntry.getPath());
    }
  }
示例#26
0
  private void fillTabs() {
    mActionBar.removeAllTabs();
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mActionBar.setSubtitle(
        StringUtils.isBlank(mSelectBranchTag) ? mRepository.getMasterBranch() : mSelectBranchTag);

    mAdapter = new RepositoryAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);

    mPager.setOnPageChangeListener(
        new OnPageChangeListener() {

          @Override
          public void onPageScrollStateChanged(int arg0) {}

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {}

          @Override
          public void onPageSelected(int arg0) {
            mActionBar.getTabAt(arg0).select();
          }
        });

    Tab tab =
        mActionBar
            .newTab()
            .setText(R.string.about)
            .setTabListener(new TabListener<SherlockFragmentActivity>(this, 0 + "", mPager));
    mActionBar.addTab(tab, mCurrentTab == 0);

    tab =
        mActionBar
            .newTab()
            .setText(R.string.repo_files)
            .setTabListener(new TabListener<SherlockFragmentActivity>(this, 1 + "", mPager));
    mActionBar.addTab(tab, mCurrentTab == 1);

    tab =
        mActionBar
            .newTab()
            .setText(getResources().getQuantityString(R.plurals.commit, 2))
            .setTabListener(new TabListener<SherlockFragmentActivity>(this, 2 + "", mPager));
    mActionBar.addTab(tab, mCurrentTab == 2);
  }
示例#27
0
 /**
  * Start an activity to view the given repository
  *
  * @param repository
  */
 @Override
 protected void viewRepository(Repository repository) {
   if (!repo.generateId().equals(repository.generateId())) super.viewRepository(repository);
 }
 @Override
 protected RepositoryPagerAdapter createAdapter() {
   return new RepositoryPagerAdapter(
       getSupportFragmentManager(), getResources(), repository.isHasIssues());
 }
示例#29
0
 /**
  * Does the repository have details denoting it was loaded from an API call?
  *
  * <p>This uses a simple heuristic of either being private, being a fork, or having a non-zero
  * amount of forks meaning it came back from an API call providing those details and more.
  *
  * @param repository
  * @return true if complete, false otherwise
  */
 public static boolean isComplete(Repository repository) {
   return repository.isPrivate() || repository.isFork() || repository.getForks() > 0;
 }
 private String getCurrentRef() {
   if (!TextUtils.isEmpty(mSelectedRef)) {
     return mSelectedRef;
   }
   return mRepository.getDefaultBranch();
 }