the text in the diagram needs to be identified through ocr in the project, and the third-party ocr library is referenced, but there is a problem in the nesting of rxjava, and the key part of the code is pasted
.Disposable disposable = Observable.just(OCR())
.observeOn(AndroidSchedulers.MainThread())
.subscribeOn(schedulers.newThread())
.flatMap(new Function<Rsult,ItemsBean>(){
............
})
.subscribe(new Consumer(){
............
})
where the ocr method itself is accessed through the network and returns the Request instance, probably posting the code of the ocr method
public static Result OCR(){
ImageClient imageClient = new ImageClient();
String result = imageClient.OCR(**,**,**);//
Result resultEntity = gson.fromJson(result);
return resultEntity;
}
after running, it is found that the result instance obtained in flatMap is empty, and then part of the code is changed to something like this
.Disposable disposable = Observable.just(imageClient.OCR(**,**,**))
.observeOn(AndroidSchedulers.MainThread())
.subscribeOn(schedulers.newThread())
.map(new Function(){
............
})
.flatMap(new Function<Rsult,ItemsBean>(){
............
})
.subscribe(new Consumer(){
............
})
then report network access in the main thread, what is the reason for this, and how to do this similar combination of network access nesting and rxjava?