<commit_before>package io.oldering.tvfoot.red.app.common;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.MainThreadDisposable;
import java.lang.ref.WeakReference;

import static io.oldering.tvfoot.red.app.common.PreConditions.checkMainThread;

/**
 * Heavily based on {@link com.jakewharton.rxbinding2.support.v7.widget.RecyclerViewScrollEventObservable}
 * and {@link com.genius.groupie.example.InfiniteScrollListener}
 */
public final class InfiniteScrollEventObservable extends Observable<Object> {
  // TODO(benoit) is it useful to use a WeakReference here?
  private final WeakReference<RecyclerView> view;

  InfiniteScrollEventObservable(RecyclerView view) {
    this.view = new WeakReference<>(view);
  }

  @Override protected void subscribeActual(Observer<? super Object> observer) {
    if (!checkMainThread(observer)) {
      return;
    }
    Listener listener = new Listener(view.get(), observer);
    observer.onSubscribe(listener);
    view.get().addOnScrollListener(listener.scrollListener);
  }

  private static final class Listener extends MainThreadDisposable {<commit_msg>fix infinite scroll's functions openness<commit_after>package io.oldering.tvfoot.red.app.common;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.MainThreadDisposable;
import java.lang.ref.WeakReference;

import static io.oldering.tvfoot.red.app.common.PreConditions.checkMainThread;

/**
 * Heavily based on {@link com.jakewharton.rxbinding2.support.v7.widget.RecyclerViewScrollEventObservable}
 * and {@link com.genius.groupie.example.InfiniteScrollListener}
 */
public final class InfiniteScrollEventObservable extends Observable<Object> {
  // TODO(benoit) is it useful to use a WeakReference here?
  private final WeakReference<RecyclerView> view;

  public InfiniteScrollEventObservable(RecyclerView view) {
    this.view = new WeakReference<>(view);
  }

  @Override protected void subscribeActual(Observer<? super Object> observer) {
    if (!checkMainThread(observer)) {
      return;
    }
    Listener listener = new Listener(view.get(), observer);
    observer.onSubscribe(listener);
    view.get().addOnScrollListener(listener.scrollListener);
  }

  private static final class Listener extends MainThreadDisposable {
{'fraction_non_alphanumeric': 0.09832802547770701, 'fraction_numerical': 0.0031847133757961785, 'mean_word_length': 5.510362694300518, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3755180', 'n_tokens_mistral': 761, 'n_tokens_neox': 714, 'n_words': 151}