Search in sources :

Example 1 with DefaultServerPolicyApi

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);
}
Also used : Disposable(io.reactivex.disposables.Disposable) DefaultServerPolicyApi(chat.rocket.android.api.rest.DefaultServerPolicyApi) ServerPolicyApi(chat.rocket.android.api.rest.ServerPolicyApi) DefaultServerPolicyApi(chat.rocket.android.api.rest.DefaultServerPolicyApi) ServerPolicyApiValidationHelper(chat.rocket.android.helper.ServerPolicyApiValidationHelper)

Aggregations

DefaultServerPolicyApi (chat.rocket.android.api.rest.DefaultServerPolicyApi)1 ServerPolicyApi (chat.rocket.android.api.rest.ServerPolicyApi)1 ServerPolicyApiValidationHelper (chat.rocket.android.helper.ServerPolicyApiValidationHelper)1 Disposable (io.reactivex.disposables.Disposable)1