public DebugApplicationInstrumentation(
      @NonNull LeakTracing leakTracing, @NonNull Instrumentation instrumentation) {

    Preconditions.checkNotNull(leakTracing, "Leak Tracing cannot be null.");
    Preconditions.checkNotNull(instrumentation, "Instrumentation cannot be null.");

    this.leakTracing = leakTracing;
    this.instrumentation = instrumentation;
  }
コード例 #2
0
  public RepositoryViewModel(
      @NonNull DataLayer.GetUserSettings getUserSettings,
      @NonNull DataLayer.FetchAndGetGitHubRepository fetchAndGetGitHubRepository) {
    Preconditions.checkNotNull(getUserSettings, "Gey User Settings cannot be null.");
    Preconditions.checkNotNull(
        fetchAndGetGitHubRepository, "Fetch And Get GitHub Repository cannot be null.");

    this.getUserSettings = getUserSettings;
    this.fetchAndGetGitHubRepository = fetchAndGetGitHubRepository;
    Log.v(TAG, "RepositoryViewModel");
  }
コード例 #3
0
  public GitHubRepositorySearchFetcher(
      @NonNull NetworkApi networkApi,
      @NonNull Action1<NetworkRequestStatus> updateNetworkRequestStatus,
      @NonNull GitHubRepositoryStore gitHubRepositoryStore,
      @NonNull GitHubRepositorySearchStore gitHubRepositorySearchStore) {
    super(networkApi, updateNetworkRequestStatus);

    Preconditions.checkNotNull(gitHubRepositoryStore, "GitHub Repository Store cannot be null.");
    Preconditions.checkNotNull(
        gitHubRepositorySearchStore, "" + "GitHub Repository Search Store cannot be null.");

    this.gitHubRepositoryStore = gitHubRepositoryStore;
    this.gitHubRepositorySearchStore = gitHubRepositorySearchStore;
  }
コード例 #4
0
  @NonNull
  private Observable<List<GitHubRepository>> createNetworkObservable(
      @NonNull final String searchString) {
    Preconditions.checkNotNull(searchString, "Search String cannot be null.");

    return networkApi.search(Collections.singletonMap("q", searchString));
  }
コード例 #5
0
  private void fetchGitHubSearch(@NonNull final String searchString) {
    Preconditions.checkNotNull(searchString, "Search String cannot be null.");

    Log.d(TAG, "fetchGitHubSearch(" + searchString + ")");
    if (requestMap.containsKey(searchString.hashCode())
        && !requestMap.get(searchString.hashCode()).isUnsubscribed()) {
      Log.d(TAG, "Found an ongoing request for repository " + searchString);
      return;
    }
    final String uri = gitHubRepositorySearchStore.getUriForKey(searchString).toString();
    Subscription subscription =
        createNetworkObservable(searchString)
            .subscribeOn(Schedulers.computation())
            .map(
                (repositories) -> {
                  final List<Integer> repositoryIds = new ArrayList<>();
                  for (GitHubRepository repository : repositories) {
                    gitHubRepositoryStore.put(repository);
                    repositoryIds.add(repository.getId());
                  }
                  return new GitHubRepositorySearch(searchString, repositoryIds);
                })
            .doOnCompleted(() -> completeRequest(uri))
            .doOnError(doOnError(uri))
            .subscribe(
                gitHubRepositorySearchStore::put,
                e ->
                    Log.e(
                        TAG,
                        "Error fetching GitHub repository search for '" + searchString + "'",
                        e));
    requestMap.put(searchString.hashCode(), subscription);
    startRequest(uri);
  }