org.eclipse.egit.github.core.Repository Java Examples

The following examples show how to use org.eclipse.egit.github.core.Repository. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void getRepositoryClones(final Repository repository, final String period,
                                final GetRepositoryClonesCallback callback) {
    new AsyncTask<Void, Void, Clones>() {
        @Override
        protected Clones doInBackground(Void... params) {
            return getRepositoryClonesSync(repository, period);
        }

        @Override
        protected void onPostExecute(Clones clones) {
            if (clones != null) {
                callback.onRepositoryClonesLoaded(clones);
            } else {
                callback.onDataNotAvailable();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #2
Source File: TrafficPresenter.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Bundle savedInstanceState, long repositoryId) {
    mView.setLoadingIndicator(true);
    mRepositoryId = repositoryId;

    mLoaderManager.initLoader(TRAFFIC_LOADER, null, TrafficPresenter.this);
    mLoaderManager.initLoader(VIEWS_LOADER, null, TrafficPresenter.this);
    mLoaderManager.initLoader(CLONES_LOADER, null, TrafficPresenter.this);
    mLoaderManager.initLoader(REFERENCES_LOADER, null, TrafficPresenter.this);

    mGithubRepository.getRepositoriesWithAdditionalInfo(repositoryId,
            new GithubDataSource.GetRepositoriesCallback() {
                @Override
                public void onRepositoriesLoaded(List<Repository> repositoryList) {
                    // Nothing to do
                }

                @Override
                public void onDataNotAvailable() {
                    // Nothing to do
                }
            }, false);
}
 
Example #3
Source File: GithubApi.java    From karamel with Apache License 2.0 6 votes vote down vote up
/**
 * Create a repository in a given github user's local account.
 *
 * @param repoName
 * @param description
 * @throws KaramelException
 */
public synchronized static void createRepoForUser(String repoName, String description) throws KaramelException {
  try {
    UserService us = new UserService(client);
    RepositoryService rs = new RepositoryService(client);
    Repository r = new Repository();
    r.setName(repoName);
    r.setOwner(us.getUser());
    r.setDescription(description);
    rs.createRepository(r);
    cloneRepo(getUser(), repoName);
    cachedRepos.remove(GithubApi.getUser());
  } catch (IOException ex) {
    throw new KaramelException("Problem creating " + repoName + " for user " + ex.getMessage());
  }
}
 
Example #4
Source File: DashboardPresenter.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onRefresh() {
    mGithubRepository.getRepositoriesWithAdditionalInfo(new GithubDataSource.GetRepositoriesCallback() {
        @Override
        public void onRepositoriesLoaded(List<Repository> repositoryList) {
            mDashboardView.setLoadingIndicator(false);
            mDashboardView.setRefreshIndicator(false);
            mLoaderManager.restartLoader(REPOSITORIES_LOADER, null,
                    DashboardPresenter.this);
        }

        @Override
        public void onDataNotAvailable() {
            DashboardPresenter.this.onDataNotAvailable(REPOSITORIES_LOADER);
        }
    }, false);
}
 
Example #5
Source File: GithubApi.java    From karamel with Apache License 2.0 6 votes vote down vote up
/**
 * Create a repository for a given organization with a description
 *
 * @param org
 * @param repoName
 * @param description
 * @return RepoItem bean/json object
 * @throws KaramelException
 */
public synchronized static RepoItem createRepoForOrg(String org, String repoName, String description) throws
    KaramelException {
  try {
    OrganizationService os = new OrganizationService(client);
    RepositoryService rs = new RepositoryService(client);
    Repository r = new Repository();
    r.setName(repoName);
    r.setOwner(os.getOrganization(org));
    r.setDescription(description);
    rs.createRepository(org, r);
    cloneRepo(org, repoName);
    cachedRepos.remove(org);
    return new RepoItem(repoName, description, r.getSshUrl());
  } catch (IOException ex) {
    throw new KaramelException("Problem creating the repository " + repoName + " for organization " + org
        + " : " + ex.getMessage());
  }
}
 
Example #6
Source File: GithubApi.java    From karamel with Apache License 2.0 6 votes vote down vote up
/**
 * Gets all repositories for a given organization/user.
 *
 * @param orgName
 * @return List of repositories
 * @throws KaramelException
 */
public synchronized static List<RepoItem> getRepos(String orgName) throws KaramelException {
  if (cachedRepos.get(orgName) != null) {
    return cachedRepos.get(orgName);
  }

  try {
    RepositoryService rs = new RepositoryService(client);
    List<Repository> repos;
    // If we are looking for the repositories for the current user
    if (GithubApi.getUser().equalsIgnoreCase(orgName)) {
      repos = rs.getRepositories(orgName);
    } else {       // If we are looking for the repositories for a given organization
      repos = rs.getOrgRepositories(orgName);
    }

    List<RepoItem> repoItems = new ArrayList<>();
    for (Repository r : repos) {
      repoItems.add(new RepoItem(r.getName(), r.getDescription(), r.getSshUrl()));
    }
    cachedRepos.put(orgName, repoItems);
    return repoItems;
  } catch (IOException ex) {
    throw new KaramelException("Problem listing GitHub repositories: " + ex.getMessage());
  }
}
 
Example #7
Source File: GitHubConnector.java    From tool.accelerate.core with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a repository on GitHub and in a local temporary directory. This is a one time operation as
 * once it is created on GitHub and locally it cannot be recreated.
 */
public File createGitRepository(String repositoryName) throws IOException {
    RepositoryService service = new RepositoryService();
    service.getClient().setOAuth2Token(oAuthToken);
    Repository repository = new Repository();
    repository.setName(repositoryName);
    repository = service.createRepository(repository);
    repositoryLocation = repository.getHtmlUrl();

    CloneCommand cloneCommand = Git.cloneRepository()
            .setURI(repository.getCloneUrl())
            .setDirectory(localGitDirectory);
    addAuth(cloneCommand);
    try {
        localRepository = cloneCommand.call();
    } catch (GitAPIException e) {
        throw new IOException("Error cloning to local file system", e);
    }
    return localGitDirectory;
}
 
Example #8
Source File: GitHubExporterTest.java    From rtc2jira with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testExport_WithDBEntries_ExpectExport(@Mocked Repository repoMock, @Mocked IssueService issueServiceMock)
    throws Exception {
  new Expectations() {
    {
      settingsMock.hasGithubProperties();
      result = true;
      _service.getRepository(anyString, anyString);
      result = repoMock;
    }
  };
  engine.withDB(db -> {
    createWorkItem(123);
    createWorkItem(324);
  });
  ExportManager exportManager = new ExportManager();
  exportManager.addExporters(exporter);
  exportManager.export(settingsMock, engine);

  new Verifications() {
    {
      issueServiceMock.createIssue(null, withInstanceOf(Issue.class));
      times = 2;
    }
  };
}
 
Example #9
Source File: GithubLocalDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
public boolean saveRepositories(List<Repository> repositories) throws IOException {
    Uri uri = RepositoryContract.RepositoryEntry.CONTENT_URI;
    for (Repository repository : repositories) {
        ContentValues repositoryValues = RepositoryContract.RepositoryEntry.
                buildContentValues(repository);

        Cursor cursor = mContentResolver.query(uri,
                new String[]{RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_ID},
                RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_ID + " = "
                        + repository.getId(), null, null);

        if (cursor != null && cursor.moveToFirst()) {
            mContentResolver.update(uri, repositoryValues,
                    RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_ID + " = "
                            + repository.getId(), null);
        } else {
            mContentResolver.insert(uri, repositoryValues);
        }

        if (cursor != null) {
            cursor.close();
        }
    }
    return true;
}
 
Example #10
Source File: GithubRepository.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
/**
 * Get the user's' repositories
 *
 * @param callback called when the repositories are loaded
 * @param useCache if false the list of repositories are updated from online
 */
@Override
public void getRepositoriesWithAdditionalInfo(final GetRepositoriesCallback callback, boolean useCache) {
    final String key = ReferrerContract.ReferrerEntry.TABLE_NAME;
    if (useCache && mSyncSettings.isSynced(key)) {
        Log.i(LOG_TAG, "Cache was used for " + key);
        callback.onRepositoriesLoaded(new ArrayList<Repository>());
        return;
    }
    mGithubRemoteDataSource.getRepositoriesWithAdditionalInfo(new GetRepositoriesCallback() {
        @Override
        public void onRepositoriesLoaded(List<Repository> repositories) {
            if (repositories.size() > 0) {
                mSyncSettings.synced(key);
            }
            callback.onRepositoriesLoaded(repositories);
        }

        @Override
        public void onDataNotAvailable() {
            callback.onDataNotAvailable();
        }
    }, useCache);
}
 
Example #11
Source File: GithubRepository.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
/**
 * Get the repository of the provided repository id
 *
 * @param repositoryId the id of the repository to find
 * @param callback     called when the repository is found or not found
 * @param useCache     whether or not the cache should be used to search for the repository
 */
@Override
public void getRepositoriesWithAdditionalInfo(long repositoryId, final GetRepositoriesCallback callback,
                                              boolean useCache) {
    final String key = ReferrerContract.ReferrerEntry.TABLE_NAME + repositoryId;
    if (useCache && mSyncSettings.isSynced(key)) {
        Log.i(LOG_TAG, "Cache was used for " + key);
        callback.onRepositoriesLoaded(new ArrayList<Repository>());
        return;
    }
    mGithubRemoteDataSource.getRepositoriesWithAdditionalInfo(repositoryId,
            new GetRepositoriesCallback() {
                @Override
                public void onRepositoriesLoaded(List<Repository> repositories) {
                    if (repositories.size() > 0) {
                        mSyncSettings.synced(key);
                    }
                    callback.onRepositoriesLoaded(repositories);
                }

                @Override
                public void onDataNotAvailable() {
                    callback.onDataNotAvailable();
                }
            }, useCache);
}
 
Example #12
Source File: JiraExporterTest.java    From rtc2jira with GNU General Public License v2.0 6 votes vote down vote up
public void testCreateOrUpdateItem(@Mocked ClientResponse clientResponse, @Mocked StorageEngine store,
    @Mocked Repository repoMock, @Mocked RepositoryService service, @Mocked IssueService issueServiceMock,
    @Mocked ODocument workItem) throws Exception {

  new Expectations() {
    {
      settings.hasJiraProperties();
      result = true;

      clientResponse.getStatus();
      result = Status.OK.getStatusCode();

      service.getRepository(anyString, anyString);
      result = repoMock;
    }
  };

  JiraExporter jiraExporter = JiraExporter.INSTANCE;
  jiraExporter.initialize(settings, store);
  jiraExporter.createOrUpdateItem(workItem);

  new Verifications() {
    {
    }
  };
}
 
Example #13
Source File: GitHubSourceConnector.java    From apicurio-studio with Apache License 2.0 6 votes vote down vote up
/**
 * @see io.apicurio.hub.api.github.IGitHubSourceConnector#getBranches(java.lang.String, java.lang.String)
 */
@Override
public Collection<SourceCodeBranch> getBranches(String org, String repo)
        throws GitHubException, SourceConnectorException {
    logger.debug("Getting the branches from {} / {}", org, repo);
    Collection<SourceCodeBranch> rval = new HashSet<>();
    try {
        GitHubClient client = githubClient();
        
        RepositoryService repoService = new RepositoryService(client);
        Repository repository = repoService.getRepository(org, repo);
        List<RepositoryBranch> branches = repoService.getBranches(repository);
        for (RepositoryBranch branch : branches) {
            SourceCodeBranch ghBranch = new SourceCodeBranch();
            ghBranch.setName(branch.getName());
            ghBranch.setCommitId(branch.getCommit().getSha());
            rval.add(ghBranch);
        }
    } catch (IOException e) {
        logger.error("Error getting GitHub branches.", e);
        throw new GitHubException("Error getting GitHub branches.", e);
    }
    return rval;
}
 
Example #14
Source File: SyncAdapter.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
                          ContentProviderClient provider, SyncResult syncResult) {
    String key = "onPerformSync";
    final GithubRemoteDataSource githubRepository =
            GithubRepository.Injection.provideRemoteDataSource(getContext());
    githubRepository.getUserSync();
    Cursor cursor = getContext().getContentResolver().query(RepositoryContract
                    .RepositoryEntry.CONTENT_URI_REPOSITORY_STARGAZERS,
            RepositoryContract.RepositoryEntry.REPOSITORY_COLUMNS_WITH_ADDITIONAL_INFO,
            null, null, null);
    boolean forceSync = cursor == null || !cursor.moveToFirst();
    if (cursor != null) {
        cursor.close();
    }

    if (mSyncSettings.isSynced(key) && !forceSync) {
        return;
    } else {
        mSyncSettings.synced(key);
    }
    List<Repository> repositories = githubRepository.getRepositoriesSync();
    githubRepository.getRepositoriesWithAdditionalInfoSync(repositories);
    githubRepository.getTrendingRepositoriesSync(githubRepository.getDefaultPeriodForTrending(),
            githubRepository.getDefaultLanguageForTrending(), false);
}
 
Example #15
Source File: RepositoryContract.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
public static ContentValues buildContentValues(Repository repo) {
    ContentValues contentValues = new ContentValues();
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_ID,
            repo.getId());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_NAME,
            repo.getName());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_FULL_NAME,
            repo.getOwner().getName() + File.separator + repo.getName());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_DESCRIPTION,
            repo.getDescription());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_PRIVATE,
            repo.isPrivate());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_FORK,
            repo.isFork());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_URL,
            repo.getUrl());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_HTML_URL,
            repo.getHtmlUrl());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_FORKS,
            repo.getForks());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_WATCHERS,
            repo.getWatchers());
    contentValues.put(RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_LANGUAGE,
            repo.getLanguage());
    return contentValues;
}
 
Example #16
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@WorkerThread
private Clones getRepositoryClonesSync(final Repository repository, String period) {
    try {
        Clones clones = GitHubAPI.traffic()
                .setToken(getToken())
                .setTokenType(getTokenType())
                .setRepository(repository)
                .setPeriod(period)
                .getClones();

        mLocalDataSource.saveClones(repository.getId(), clones);

        return clones;

    } catch (IOException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        return null;
    }
}
 
Example #17
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void getRepositoriesWithAdditionalInfo(final long repositoryId,
                                              final GetRepositoriesCallback callback, boolean useCache) {
    new AsyncTask<Void, Void, List<Repository>>() {
        @Override
        protected List<Repository> doInBackground(Void... params) {
            List<Repository> repositories = getRepositoriesSync();
            getRepositoriesWithAdditionalInfoSync(repositoryId, repositories);
            return repositories;
        }

        @Override
        protected void onPostExecute(List<Repository> repositoryList) {
            if (repositoryList != null) {
                callback.onRepositoriesLoaded(repositoryList);
            } else {
                callback.onDataNotAvailable();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #18
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void getRepositoriesWithAdditionalInfo(final GetRepositoriesCallback callback, boolean useCache) {
    new AsyncTask<Void, Void, List<Repository>>() {
        @Override
        protected List<Repository> doInBackground(Void... params) {
            List<Repository> repositories = getRepositoriesSync();
            getRepositoriesWithAdditionalInfoSync(repositories);
            return repositories;
        }

        @Override
        protected void onPostExecute(List<Repository> repositoryList) {
            if (repositoryList != null) {
                callback.onRepositoriesLoaded(repositoryList);
            } else {
                callback.onDataNotAvailable();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #19
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@WorkerThread
private Views getRepositoryViewsSync(final Repository repository, String period) {
    try {
        Views views = GitHubAPI.traffic()
                .setToken(getToken())
                .setTokenType(getTokenType())
                .setRepository(repository)
                .setPeriod(period)
                .getViews();

        mLocalDataSource.saveViews(repository.getId(), views);
        return views;

    } catch (IOException e) {
        if (Utils.isNetworkAvailable()) {
            FirebaseCrash.report(e);
        }
        return null;
    }
}
 
Example #20
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void getRepositories(final GetRepositoriesCallback callback) {
    new AsyncTask<Void, Void, List<Repository>>() {
        @Override
        protected List<Repository> doInBackground(Void... params) {
            return getRepositoriesSync();
        }

        @Override
        protected void onPostExecute(List<Repository> repositoryList) {
            if (repositoryList != null) {
                callback.onRepositoriesLoaded(repositoryList);
            } else {
                callback.onDataNotAvailable();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #21
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void getRepositoryViews(final Repository repository, final String period,
                               final GetRepositoryViewsCallback callback) {
    new AsyncTask<Void, Void, Views>() {
        @Override
        protected Views doInBackground(Void... params) {
            return getRepositoryViewsSync(repository, period);
        }

        @Override
        protected void onPostExecute(Views views) {
            if (views != null) {
                callback.onRepositoryViewsLoaded(views);
            } else {
                callback.onDataNotAvailable();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #22
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
@WorkerThread
private List<ReferringSite> getRepositoryReferrersSync(final Repository repository) {
    try {
        List<ReferringSite> referringSites = GitHubAPI.traffic()
                .setToken(getToken())
                .setTokenType(getTokenType())
                .setRepository(repository)
                .getReferringSites();
        mLocalDataSource.saveReferringSites(repository.getId(), referringSites);
        return referringSites;
    } catch (IOException e) {
        if (Utils.isNetworkAvailable()) {
            FirebaseCrash.report(e);
        }
        return null;
    }
}
 
Example #23
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void getRepositoryReferrers(final Repository repository,
                                   final GetRepositoryReferrersCallback callback) {
    new AsyncTask<Void, Void, List<ReferringSite>>() {
        @Override
        protected List<ReferringSite> doInBackground(Void... params) {
            return getRepositoryReferrersSync(repository);
        }

        @Override
        protected void onPostExecute(List<ReferringSite> referringSiteList) {
            if (referringSiteList != null) {
                callback.onRepositoryReferrersLoaded(referringSiteList);
            } else {
                callback.onDataNotAvailable();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #24
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
public void getStargazers(final Repository repository, final GetStargazersCallback callback) {
    new AsyncTask<Void, Void, List<Star>>() {
        @Override
        protected List<Star> doInBackground(Void... params) {
            return getStargazersSync(repository);
        }

        @Override
        protected void onPostExecute(List<Star> starList) {
            if (starList != null) {
                callback.onStargazersLoaded(starList);
            } else {
                callback.onDataNotAvailable();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #25
Source File: GithubRemoteDataSource.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@WorkerThread
private List<Star> getStargazersSync(Repository repository) {
    try {
        List<Star> stars = GitHubAPI.stargazers()
                .setToken(getToken())
                .setTokenType(getTokenType())
                .setRepository(repository)
                .setPage(Service.Pagination.LAST_PAGE)
                .setDate(Utils.twoWeeksAgo())
                .getStars();
        mLocalDataSource.saveStargazers(repository, stars);
        return stars;
    } catch (IOException e) {
        if (Utils.isNetworkAvailable()) {
            FirebaseCrash.report(e);
        }
        return null;
    }
}
 
Example #26
Source File: PublicRepositoryPresenter.java    From gito-github-client with Apache License 2.0 6 votes vote down vote up
@Override
public void onRefresh() {
    mGithubRepository.getRepositories(new GithubDataSource.GetRepositoriesCallback() {
        @Override
        public void onRepositoriesLoaded(List<Repository> repositoryList) {
            mPublicRepositoriesView.setLoadingIndicator(false);
            mPublicRepositoriesView.setRefreshIndicator(false);
            mLoaderManager.restartLoader(REPOSITORIES_LOADER,
                    null,
                    PublicRepositoryPresenter.this);
        }

        @Override
        public void onDataNotAvailable() {
            PublicRepositoryPresenter.this.onDataNotAvailable(REPOSITORIES_LOADER);
        }
    });
}
 
Example #27
Source File: ForkRepositoryWorkitemHandler.java    From jbpm-work-items with Apache License 2.0 5 votes vote down vote up
public void executeWorkItem(WorkItem workItem,
                            WorkItemManager workItemManager) {
    try {

        RequiredParameterValidator.validate(this.getClass(),
                                            workItem);

        Map<String, Object> results = new HashMap<String, Object>();

        String repoOwner = (String) workItem.getParameter("RepoOwner");
        String repoName = (String) workItem.getParameter("RepoName");
        String organization = (String) workItem.getParameter("Organization");

        Repository forkedRepository;

        RepositoryService repoService = auth.getRespositoryService(this.userName,
                                                                   this.password);

        RepositoryId toBeForkedRepo = new RepositoryId(repoOwner,
                                                       repoName);
        if (StringUtils.isNotEmpty(organization)) {
            forkedRepository = repoService.forkRepository(toBeForkedRepo,
                                                          organization);
        } else {
            forkedRepository = repoService.forkRepository(toBeForkedRepo);
        }

        results.put(RESULTS_VALUE,
                    new RepositoryInfo(forkedRepository));

        workItemManager.completeWorkItem(workItem.getId(),
                                         results);
    } catch (Exception e) {
        handleException(e);
    }
}
 
Example #28
Source File: StarTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPostExecute(Boolean result) {
    if (result) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

        list.clear();
        while (iterator.hasNext()) {
            Repository r = iterator.next();
            list.add(
                    new StarItem(
                            r.getName(),
                            format.format(r.getCreatedAt()),
                            r.getDescription(),
                            r.getLanguage(),
                            r.getWatchers(),
                            r.getForks(),
                            r.getOwner().getLogin(),
                            r.getGitUrl()
                    )
            );
        }

        if (list.size() <= 0) {
            bookmark.setVisible(false);
            fragment.setContentEmpty(true);
            fragment.setEmptyText(R.string.repo_empty_list);
            fragment.setContentShown(true);
        } else {
            bookmark.setVisible(true);
            fragment.setContentEmpty(false);
            adapter.notifyDataSetChanged();
            fragment.setContentShown(true);
        }
    } else {
        bookmark.setVisible(false);
        fragment.setContentEmpty(true);
        fragment.setEmptyText(R.string.repo_empty_error);
        fragment.setContentShown(true);
    }
}
 
Example #29
Source File: StarTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected Boolean doInBackground(Void... params) {
    PageIterator<Repository> pageIterator = service.pageWatched(17);
    iterator = pageIterator.next().iterator();

    if (isCancelled()) {
        return false;
    }
    return true;
}
 
Example #30
Source File: CommitTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected Boolean doInBackground(Void... params) {
    Iterator<RepositoryCommit> iterator;
    try {
        Repository repository = repositoryService.getRepository(repoItem.getOwner(), repoItem.getTitle());
        PageIterator<RepositoryCommit> pageIterator = commitService.pageCommits(repository, 20);
        iterator = pageIterator.next().iterator();
    } catch (IOException i) {
        return false;
    }

    if (isCancelled()) {
        return false;
    }

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    commitItemList.clear();
    while (iterator.hasNext()) {
        RepositoryCommit commit = iterator.next();

        String date = simpleDateFormat.format(commit.getCommit().getAuthor().getDate());
        commitItemList.add(
                new CommitItem(
                        context.getResources().getDrawable(R.drawable.ic_action_push),
                        commit.getCommit().getAuthor().getName(),
                        date,
                        commit.getCommit().getMessage()
                )
        );
    }

    if (isCancelled()) {
        return false;
    }
    return true;
}