@Test public void testEmailError() { ContactModel model = viewModel.initAndResume(); compileForm(model, "aaa", "aaa", "aaa"); viewModel.send(); checkErrors(model, 0, R.string.invalid_email, 0); }
public void send() { model.sendPressed = true; if (validate()) { Completable observable = mailJetService.sendEmail( model.name + " <info@cosenonjaviste.it>", "info@cosenonjaviste.it", "Email from " + model.name, "Reply to: " + model.email + "\n" + model.message ); sending.set(true); disposable.add(observable .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> sending.set(false)) .subscribe( () -> navigator.showMessage(R.string.message_sent), t -> navigator.showMessage(R.string.error_sending_message)) ); } }
ContactViewModel extends RxViewModel<Void, ContactModel> { public void send() { model.sendPressed = true; if (validate()) { Completable observable = mailJetService.sendEmail( model.name + " <info@cosenonjaviste.it>", "info@cosenonjaviste.it", "Email from " + model.name, "Reply to: " + model.email + "\n" + model.message ); sending.set(true); disposable.add(observable .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> sending.set(false)) .subscribe( () -> navigator.showMessage(R.string.message_sent), t -> navigator.showMessage(R.string.error_sending_message)) ); } } }
ContactViewModel extends RxViewModel<Void, ContactModel> { public void send() { model.sendPressed = true; if (validate()) { Completable observable = mailJetService.sendEmail( model.name + " <info@cosenonjaviste.it>", "info@cosenonjaviste.it", "Email from " + model.name, "Reply to: " + model.email + "\n" + model.message ); sending.set(true); disposable.add(observable .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> sending.set(false)) .subscribe( () -> navigator.showMessage(R.string.message_sent), t -> navigator.showMessage(R.string.error_sending_message)) ); } } @Inject  ContactViewModel(); }
ContactViewModel extends RxViewModel<Void, ContactModel> { public void send() { model.sendPressed = true; if (validate()) { Completable observable = mailJetService.sendEmail( model.name + " <info@cosenonjaviste.it>", "info@cosenonjaviste.it", "Email from " + model.name, "Reply to: " + model.email + "\n" + model.message ); sending.set(true); disposable.add(observable .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> sending.set(false)) .subscribe( () -> navigator.showMessage(R.string.message_sent), t -> navigator.showMessage(R.string.error_sending_message)) ); } } @Inject  ContactViewModel(); @Override void resume(); @Override void pause(); void send(); }
ContactViewModel extends RxViewModel<Void, ContactModel> { public void send() { model.sendPressed = true; if (validate()) { Completable observable = mailJetService.sendEmail( model.name + " <info@cosenonjaviste.it>", "info@cosenonjaviste.it", "Email from " + model.name, "Reply to: " + model.email + "\n" + model.message ); sending.set(true); disposable.add(observable .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> sending.set(false)) .subscribe( () -> navigator.showMessage(R.string.message_sent), t -> navigator.showMessage(R.string.error_sending_message)) ); } } @Inject  ContactViewModel(); @Override void resume(); @Override void pause(); void send(); final ObservableBoolean sending; }