只会走到log的333333333这边,然后通过tolist转成list<String>形式,就不往下走了,如果去掉tolist,可以执行subscribe.
只是我需要先将数据转成需要的List集合,再执行subscribe
只是我需要先将数据转成需要的List集合,再执行subscribe
mModel.getAllSearchHistoryCache().filter(new Func1<RealmResults<SearchHistoryBean>, Boolean>() {
@Override
public Boolean call(RealmResults<SearchHistoryBean> searchHistoryBeen) {
Logger.e("111111111");
return searchHistoryBeen.isLoaded();
}
}).flatMap(new Func1<RealmResults<SearchHistoryBean>, Observable<SearchHistoryBean>>() {
@Override
public Observable<SearchHistoryBean> call(RealmResults<SearchHistoryBean> searchHistoryBeen) {
Logger.e("2222222222");
return Observable.from(searchHistoryBeen);
}
}).map(new Func1<SearchHistoryBean, String>() {
@Override
public String call(SearchHistoryBean searchHistoryBean) {
Logger.e("3333333333");
return searchHistoryBean.getKeyWord();
}
}).toList().observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<List<String>>() {
@Override
public void onCompleted() {
Logger.e("onCompleted");
}
@Override
public void onError(Throwable e) {
Logger.e("onError");
}
@Override
public void onNext(List<String> strings) {
Logger.e("strings:"+strings);
mView.showSearchHistoryList(strings);
}
});