Exemplo n.º 1
0
  private Observable<Boolean> activeState() {
    Observable<FragmentEvent> startStopLifecycle =
        lifecycle().filter(ev -> ev == FragmentEvent.START || ev == FragmentEvent.STOP);

    // now combine with the activeStateSubject and return a new observable with
    // the "active state".
    Observable<Boolean> combined =
        combineLatest(
            startStopLifecycle,
            activeStateSubject,
            (ev, active) -> active && ev == FragmentEvent.START);

    return combined.distinctUntilChanged();
  }