use of chat.rocket.android.api.rest.DefaultServerPolicyApi in project Rocket.Chat.Android by RocketChat.
the class InputHostnamePresenter method connectToEnforced.
public void connectToEnforced(final String hostname) {
final ServerPolicyApi serverPolicyApi = new DefaultServerPolicyApi(OkHttpHelper.getClientForUploadFile(), hostname);
final ServerPolicyApiValidationHelper validationHelper = new ServerPolicyApiValidationHelper(serverPolicyApi);
clearSubscriptions();
final Disposable subscription = ServerPolicyHelper.isApiVersionValid(validationHelper).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).doOnTerminate(() -> view.hideLoader()).subscribe(serverValidation -> {
if (serverValidation.isValid()) {
onServerValid(hostname, serverValidation.usesSecureConnection());
} else {
view.showInvalidServerError();
}
}, throwable -> view.showConnectionError());
addSubscription(subscription);
}
Aggregations