// Path: mobile/src/main/java/io/ashdavies/eternity/rx/AbstractViewError.java
// public class AbstractViewError<View extends AbstractView> implements Consumer<Throwable> {
// 
//   private final View view;
// 
//   public AbstractViewError(View view) {
//     this.view = view;
//   }
// 
//   @Override
//   public void accept(@NonNull Throwable throwable) throws Exception {
//     view.onError(throwable);
//   }
// }
// 
// Path: mobile/src/main/java/io/ashdavies/eternity/rx/EqualityPredicate.java
// public class EqualityPredicate<T> implements Predicate<T> {
// 
//   private final T t;
// 
//   public EqualityPredicate(T t) {
//     this.t = t;
//   }
// 
//   @Override
//   public boolean test(@NonNull T t) throws Exception {
//     return this.t.equals(t);
//   }
// }


import android.content.Intent;
import android.support.annotation.NonNull;
import io.ashdavies.commons.presenter.AbstractViewPresenter;
import io.ashdavies.commons.view.AbstractView;
import io.ashdavies.eternity.rx.AbstractViewError;
import io.ashdavies.eternity.rx.EqualityPredicate;
import io.ashdavies.rx.rxfirebase.RxFirebaseAuth;
import javax.inject.Inject;
package io.ashdavies.eternity.signin;


public class SignInPresenter extends AbstractViewPresenter<SignInPresenter.View> {

  @Inject GoogleSignInApi client;

  @Inject
  SignInPresenter() {
  }

  @Override
  protected void onViewAttached(@NonNull View view) {
    client.onConnectionEvent()
        .filter(new EqualityPredicate<>(GoogleSignInApi.Event.CONNECTED))
        .doOnNext(event -> RxFirebaseAuth.getInstance().signOut())
// Path: mobile/src/main/java/io/ashdavies/eternity/rx/AbstractViewError.java
// public class AbstractViewError<View extends AbstractView> implements Consumer<Throwable> {
// 
//   private final View view;
// 
//   public AbstractViewError(View view) {
//     this.view = view;
//   }
// 
//   @Override
//   public void accept(@NonNull Throwable throwable) throws Exception {
//     view.onError(throwable);
//   }
// }
// 
// Path: mobile/src/main/java/io/ashdavies/eternity/rx/EqualityPredicate.java
// public class EqualityPredicate<T> implements Predicate<T> {
// 
//   private final T t;
// 
//   public EqualityPredicate(T t) {
//     this.t = t;
//   }
// 
//   @Override
//   public boolean test(@NonNull T t) throws Exception {
//     return this.t.equals(t);
//   }
// }


// Path: mobile/src/main/java/io/ashdavies/eternity/signin/SignInPresenter.java
import android.content.Intent;
import android.support.annotation.NonNull;
import io.ashdavies.commons.presenter.AbstractViewPresenter;
import io.ashdavies.commons.view.AbstractView;
import io.ashdavies.eternity.rx.AbstractViewError;
import io.ashdavies.eternity.rx.EqualityPredicate;
import io.ashdavies.rx.rxfirebase.RxFirebaseAuth;
import javax.inject.Inject;

package io.ashdavies.eternity.signin;


public class SignInPresenter extends AbstractViewPresenter<SignInPresenter.View> {

  @Inject GoogleSignInApi client;

  @Inject
  SignInPresenter() {
  }

  @Override
  protected void onViewAttached(@NonNull View view) {
    client.onConnectionEvent()
        .filter(new EqualityPredicate<>(GoogleSignInApi.Event.CONNECTED))
        .doOnNext(event -> RxFirebaseAuth.getInstance().signOut())
        .subscribe(event -> client.signOut(), new AbstractViewError<>(getView()));