<commit_before>package com.kickstarter.presenters;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Pair;

import com.kickstarter.KsrApplication;
import com.kickstarter.R;
import com.kickstarter.libs.Presenter;
import com.kickstarter.libs.RxUtils;
import com.kickstarter.models.Project;
import com.kickstarter.services.ApiClient;
import com.kickstarter.services.DiscoveryParams;
import com.kickstarter.ui.activities.DiscoveryActivity;
import com.kickstarter.ui.activities.ThanksActivity;

import java.util.List;

import javax.inject.Inject;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.subjects.PublishSubject;
import timber.log.Timber;

public class ThanksPresenter extends Presenter<ThanksActivity> {
  private final PublishSubject<Void> shareClick = PublishSubject.create();
  private final PublishSubject<Void> doneClick = PublishSubject.create();

  @Inject ApiClient apiClient;

  @Override
  protected void onCreate(final Context context, final Bundle savedInstanceState) {
    super.onCreate(context, savedInstanceState);
    ((KsrApplication) context.getApplicationContext()).component().inject(this);
  }

  public void takeProject(final Project project) {
    final Observable<Pair<ThanksActivity, Project>> viewAndProject = RxUtils.combineLatestPair(viewSubject, Observable.just(project))
      .filter(vp -> vp.first != null);

    addSubscription(viewAndProject
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(vp -> vp.first.show(vp.second)));

    addSubscription(shareClick.withLatestFrom(viewAndProject, (click, pair) -> pair)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(vp -> vp.first.startShareIntent(vp.second)));

    addSubscription(RxUtils.combineLatestPair(viewSubject.filter(v -> v != null), doneClick)
      .map(vp -> vp.first)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(ThanksActivity::startDiscoveryActivity));

    // TODO: Should use the project category root
    DiscoveryParams params = new DiscoveryParams.Builder()
      .category(project.category())
      .backed(-1)
      .build();

    Observable<List<Project>> recommendedProjects = apiClient.fetchProjects(params)
      .map(envelope -> envelope.projects);

    addSubscription(RxUtils.combineLatestPair(viewSubject.filter(v -> v != null), recommendedProjects)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(vp -> vp.first.showRecommendedProjects(vp.second)));
  }

  public void takeDoneClick() {
    doneClick.onNext(null);
  }

  public void takeShareClick() {
    shareClick.onNext(null);
  }

  // TODO: Hook this up
/*  public void onProjectClicked(final Project project, final MiniProjectsViewHolder viewHolder) {
    Timber.d("Project clicked");
  }*/
}
<commit_msg>Missing finals<commit_after>package com.kickstarter.presenters;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Pair;

import com.kickstarter.KsrApplication;
import com.kickstarter.R;
import com.kickstarter.libs.Presenter;
import com.kickstarter.libs.RxUtils;
import com.kickstarter.models.Project;
import com.kickstarter.services.ApiClient;
import com.kickstarter.services.DiscoveryParams;
import com.kickstarter.ui.activities.DiscoveryActivity;
import com.kickstarter.ui.activities.ThanksActivity;

import java.util.List;

import javax.inject.Inject;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.subjects.PublishSubject;
import timber.log.Timber;

public class ThanksPresenter extends Presenter<ThanksActivity> {
  private final PublishSubject<Void> shareClick = PublishSubject.create();
  private final PublishSubject<Void> doneClick = PublishSubject.create();

  @Inject ApiClient apiClient;

  @Override
  protected void onCreate(final Context context, final Bundle savedInstanceState) {
    super.onCreate(context, savedInstanceState);
    ((KsrApplication) context.getApplicationContext()).component().inject(this);
  }

  public void takeProject(final Project project) {
    final Observable<Pair<ThanksActivity, Project>> viewAndProject = RxUtils.combineLatestPair(viewSubject, Observable.just(project))
      .filter(vp -> vp.first != null);

    addSubscription(viewAndProject
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(vp -> vp.first.show(vp.second)));

    addSubscription(shareClick.withLatestFrom(viewAndProject, (click, pair) -> pair)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(vp -> vp.first.startShareIntent(vp.second)));

    addSubscription(RxUtils.combineLatestPair(viewSubject.filter(v -> v != null), doneClick)
      .map(vp -> vp.first)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(ThanksActivity::startDiscoveryActivity));

    // TODO: Should use the project category root
    final DiscoveryParams params = new DiscoveryParams.Builder()
      .category(project.category())
      .backed(-1)
      .build();

    final Observable<List<Project>> recommendedProjects = apiClient.fetchProjects(params)
      .map(envelope -> envelope.projects);

    addSubscription(RxUtils.combineLatestPair(viewSubject.filter(v -> v != null), recommendedProjects)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(vp -> vp.first.showRecommendedProjects(vp.second)));
  }

  public void takeDoneClick() {
    doneClick.onNext(null);
  }

  public void takeShareClick() {
    shareClick.onNext(null);
  }

  // TODO: Hook this up
/*  public void onProjectClicked(final Project project, final MiniProjectsViewHolder viewHolder) {
    Timber.d("Project clicked");
  }*/
}

{'fraction_non_alphanumeric': 0.11261182248728294, 'fraction_numerical': 0.00035081564637782847, 'mean_word_length': 4.902691511387164, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6720220', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1637, 'n_words': 307}