Skip to content

Instantly share code, notes, and snippets.

@agustinsivoplas
Created October 31, 2016 14:22
Show Gist options
  • Save agustinsivoplas/d41b844fc363f0086d04aeda91b9ccb5 to your computer and use it in GitHub Desktop.
Save agustinsivoplas/d41b844fc363f0086d04aeda91b9ccb5 to your computer and use it in GitHub Desktop.
@BindView(R.id.button)
AppCompatButton button;
CompositeSubscription compositeSubscription;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_reachout);
ButterKnife.bind(this);
compositeSubscription = new CompositeSubscription();
/*Subscription testSubscription = RxView.clicks(button)
.subscribe(aVoid -> {
makeApiCall();
});*/
AuthenticationAPI authApi = ReachoutServiceCreator.createService(AuthenticationAPI.class, null);
RxView.clicks(button)
.flatMap(aVoid -> authApi.verifyEmail("test@retrofit.com"))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(verifyEmailResponse -> Log.i("TEST", "onNext: " + verifyEmailResponse.success),
throwable -> Log.e("TEST", "onError: " + throwable.getMessage(), throwable),
() -> Log.i("TEST", "completed"));
// compositeSubscription.add(testSubscription);
}
private void makeApiCall() {
AuthenticationAPI authApi = ReachoutServiceCreator.createService(AuthenticationAPI.class, null);
authApi.verifyEmail("test@retrofit.com").observeOn(AndroidSchedulers.mainThread())
.subscribe(verifyEmailResponse -> Log.i("TEST", "onNext: " + verifyEmailResponse.success),
throwable -> Log.e("TEST", "onError: " + throwable.getMessage(), throwable),
() -> Log.i("TEST", "completed"))
;
}
@Override
protected void onDestroy() {
compositeSubscription.unsubscribe();
super.onDestroy();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment