Search in sources :

Example 1 with GitHubRepositorySearch

use of io.reark.rxgithubapp.shared.pojo.GitHubRepositorySearch in project reark by reark.

the class GitHubRepositorySearchFetcher method fetchGitHubSearch.

private void fetchGitHubSearch(@NonNull final String searchString) {
    checkNotNull(searchString);
    Log.d(TAG, "fetchGitHubSearch(" + searchString + ")");
    if (isOngoingRequest(searchString.hashCode())) {
        Log.d(TAG, "Found an ongoing request for repository " + searchString);
        return;
    }
    final String uri = getUniqueId(searchString);
    Subscription subscription = createNetworkObservable(searchString).subscribeOn(Schedulers.computation()).map((repositories) -> {
        final List<Integer> repositoryIds = new ArrayList<>(repositories.size());
        for (GitHubRepository repository : repositories) {
            gitHubRepositoryStore.put(repository);
            repositoryIds.add(repository.getId());
        }
        return new GitHubRepositorySearch(searchString, repositoryIds);
    }).doOnSubscribe(() -> startRequest(uri)).doOnCompleted(() -> completeRequest(uri)).doOnError(doOnError(uri)).subscribe(gitHubRepositorySearchStore::put, e -> Log.e(TAG, "Error fetching GitHub repository search for '" + searchString + "'", e));
    addRequest(searchString.hashCode(), subscription);
}
Also used : ArrayList(java.util.ArrayList) GitHubRepositorySearch(io.reark.rxgithubapp.shared.pojo.GitHubRepositorySearch) Subscription(rx.Subscription) GitHubRepository(io.reark.rxgithubapp.shared.pojo.GitHubRepository)

Example 2 with GitHubRepositorySearch

use of io.reark.rxgithubapp.shared.pojo.GitHubRepositorySearch in project reark by reark.

the class RepositoriesViewModelTest method testAnyValueReportedAsIdle.

@Test
public void testAnyValueReportedAsIdle() {
    GitHubRepositorySearch value = new GitHubRepositorySearch("", Collections.emptyList());
    assertEquals(IDLE, toProgressStatus().call(onNext(value)));
}
Also used : GitHubRepositorySearch(io.reark.rxgithubapp.shared.pojo.GitHubRepositorySearch) GetGitHubRepositorySearch(io.reark.rxgithubapp.shared.data.DataFunctions.GetGitHubRepositorySearch) Test(org.junit.Test)

Aggregations

GitHubRepositorySearch (io.reark.rxgithubapp.shared.pojo.GitHubRepositorySearch)2 GetGitHubRepositorySearch (io.reark.rxgithubapp.shared.data.DataFunctions.GetGitHubRepositorySearch)1 GitHubRepository (io.reark.rxgithubapp.shared.pojo.GitHubRepository)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Subscription (rx.Subscription)1