Here is the code
getCompositeDisposable().add(Single.fromCallable(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
URL url = new URL(pageUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
int code = connection.getResponseCode(); // <- crashes here
return code == 200;
}
})
.observeOn(getSchedulerProvider().io())
.subscribeOn(getSchedulerProvider().ui())
.subscribe((pageAvailable) -> {
boolean useCache = !pageAvailable;
getMvpView().loadPage(useCache, pageUrl);
}, Timber::e)
);
Cant understand what is the problem here. The network code should be run on io thread and then return result to ui thread. Does this code even runs on io thread? Im confused.