<commit_before>package com.jetlag.jcreator.activity.chatstory;

import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repositories;
import com.google.android.agera.Updatable;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by vince on 31/08/16.
 */
public class ChatStoryPresenter implements ChatStoryActions {

  private MutableRepository<String> nextParagraphTextRepo;
  private ParagraphsRepository paragraphsRepo;

  public void createRepos() {
    nextParagraphTextRepo = Repositories.mutableRepository("");
  }

  public void addParagraph(String newParagraph) {
    nextParagraphTextRepo.accept(newParagraph);
  }

  public void bindUpdatables(ChatStoryDisplay chatStoryDisplay) {
    paragraphsRepo = new ParagraphsRepository(chatStoryDisplay);
    nextParagraphTextRepo.addUpdatable(paragraphsRepo);
  }

  public void unbindUpdatables() {
    nextParagraphTextRepo.removeUpdatable(paragraphsRepo);
  }

  private class ParagraphsRepository implements Updatable {

    private List<String> paragraphs = new ArrayList<>();

    private final ChatStoryDisplay chatStoryDisplay;

    private ParagraphsRepository(ChatStoryDisplay chatStoryDisplay) {
      this.chatStoryDisplay = chatStoryDisplay;
    }

    @Override
    public void update() {
      paragraphs.add(nextParagraphTextRepo.get());
      chatStoryDisplay.displayParagraphs(paragraphs);
    }
  }
}<commit_msg>trying to match agera spirit<commit_after>package com.jetlag.jcreator.activity.chatstory;

import android.support.annotation.NonNull;

import com.google.android.agera.Merger;
import com.google.android.agera.MutableRepository;
import com.google.android.agera.Repositories;
import com.google.android.agera.Repository;
import com.google.android.agera.Updatable;

import java.util.ArrayList;

/**
 * Created by vince on 31/08/16.
 */
public class ChatStoryPresenter implements ChatStoryActions {

  private MutableRepository<String> nextParagraphTextRepo;
  private ParagraphsUpdatable paragraphsUpdatable;
  private MutableRepository<ArrayList<String>> paragraphsRepo;
  private Repository<ArrayList<String>> paragraphsBuilder;

  public void createRepos() {
    nextParagraphTextRepo = Repositories.mutableRepository("");
    paragraphsRepo = Repositories.mutableRepository(new ArrayList<String>());
    paragraphsBuilder = Repositories.repositoryWithInitialValue(new ArrayList<String>())
        .observe(nextParagraphTextRepo)
        .onUpdatesPerLoop()
        .getFrom(nextParagraphTextRepo)
        .mergeIn(paragraphsRepo, new Merger<String, ArrayList<String>, ArrayList<String>>() {
          @NonNull
          @Override
          public ArrayList<String> merge(@NonNull String nextParagraph, @NonNull ArrayList<String> paragraphs) {
            paragraphs.add(nextParagraph);
            return paragraphs;
          }
        })
        .thenGetFrom(paragraphsRepo)
        .compile();
  }

  public void addParagraph(String newParagraph) {
    nextParagraphTextRepo.accept(newParagraph);
  }

  public void bindUpdatables(ChatStoryDisplay chatStoryDisplay) {
    paragraphsUpdatable = new ParagraphsUpdatable(chatStoryDisplay);
    paragraphsBuilder.addUpdatable(paragraphsUpdatable);
  }

  public void unbindUpdatables() {
    paragraphsBuilder.removeUpdatable(paragraphsUpdatable);
  }

  private class ParagraphsUpdatable implements Updatable {

    private final ChatStoryDisplay chatStoryDisplay;

    private ParagraphsUpdatable(ChatStoryDisplay chatStoryDisplay) {
      this.chatStoryDisplay = chatStoryDisplay;
    }

    @Override
    public void update() {
      chatStoryDisplay.displayParagraphs(paragraphsBuilder.get());
    }
  }
}
{'fraction_non_alphanumeric': 0.08412483039348712, 'fraction_numerical': 0.0032564450474898234, 'mean_word_length': 4.653374233128834, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '4943460', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1041, 'n_words': 187}