我有对象
public class Response {
private List<Content> content;
public static class Content {
private boolean rated;
}
}
我希望按List<Content> content
值过滤rated
。我试着这样做
mResponseProvider.reponse()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMapIterable(response -> response.getContent())
.filter(content -> mAAA.isRated(content.getRated()))
.toList()
.subscribe(response -> {
doSomethingWithResponse(response);
});
但问题是response
中的.subscribe()
是List<Content>
。如何使用.subscribe()
的过滤值访问Response
List<Content>
个对象?
答案 0 :(得分:0)
mResponseProvider.reponse()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.filter(response -> mAAA.isRated(response.getContent())) //1
.subscribe(response -> {
doSomethingWithResponse(response);
});
// 1尝试将参数更改为isRated中的List