Hello.
I just started trying to deal with RxJava and for several hours now I've been RxJava to execute the method in a separate thread for each list item. The bottom line is this: there is an ArrayList some Photo objects. For each of them, you need to perform a method that works with the network and increase the value inside the progress bar of the dialog box after each execution. Now it looks like this for me:
Observable.defer(() -> Observable.just(photoArrayList)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .flatMapIterable(list -> list) .filter(photo -> photo != null) .map(photo -> некийМетод(photo)) .subscribe(result -> loadingDialog.incrementProgress(1), e -> onImagesUploadComplete(false), () -> onImagesUploadComplete(true)); Obviously, this is done clumsily and throws a NetworkOnMainThreadException .
Honestly, I don’t understand where else, except in the just() method you can run a method not in the UI stream? Thank you in advance for your response.