1

Topic: RxJava: sequence of requests with change of statuses UI

All greetings smile
At an application launch, opens , consisting of progressbar for display of the status of loading and textview, in which in which the specific step which is fulfilled at a present situation is displayed.
The purpose given  to obtain some data from the server (the version urgency, the updated adjustments, the information on the user, etc.). All works in a sheaf retrofit + rxjava.
Upon, for each request there is the Observable. All of them should be fulfilled by turns (through flatMap or zip).
Problem in that I cannot update statuses of working off of methods in textview, after each fulfilled \outstanding request as I have no access to mainThread.

_view.setStatusMessageText ("connection Stock-taking");
Observable.just (appId)
.flatMap (app-> {
if (! NetworkHelper.hasConnection (ApplicationCore.getAppContext())
throw new RuntimeException (ApplicationCore.getAppContext ().getString (R.string.error_no_connections));
if (! NetworkHelper.isHostAvailable (BuildConfig.apiServerIP, BuildConfig.apiServerPort, BuildConfig. TIMEOUT))
throw new RuntimeException (ApplicationCore.getAppContext ().getString (R.string.error_service_not_available));
return Observable.just (app);
})
/*
Somehow so: _view.setStatusMessageText ("It is received the actual version"); */
.flatMap (app-> getApplicationVersions (appId))
/* _view.setStatusMessageText ("we Receive the module list"); */
.flatMap (app-> getApplicationModules (appId))
.subscribeOn (Schedulers.newThread ())
.observeOn (AndroidSchedulers.mainThread ())
.subscribe (apps-> {
/* any action */
};
throwable-> {
_view.showError (ExceptionHelper.tryParseException (throwable, TAG, 4));
_view.hideLoading ();
});

Prompt how to update UI between the fulfilled requests (Observable)?

2

Re: RxJava: sequence of requests with change of statuses UI

I apologize, ...
It is necessary to switch between flows observeOn:

.observeOn (AndroidSchedulers.mainThread ())
.doOnNext (app-> _view.setStatusMessageText ("we Receive the module list"))
.observeOn (Schedulers.io ())
.flatMap (app-> getApplicationModules (appId))