我正在使用我的代码中的RxAndroid
从object
中删除某些list
,但是在巨大的list
中却出现了以下错误,并且不删除任何{{1 }}:
object
这是我的代码java.lang.NumberFormatException: null
:
RxAndroid
并且:
public void updateListBaseSubject(String subject, String idServer) {
Integer serverId = Integer.parseInt(idServer);
if (shortTermCoursesModels != null && !shortTermCoursesModels.isEmpty()) {
mCompositeDisposable.add(observableSubject(subject, serverId, shortTermCoursesModels)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(@NonNull Disposable disposable) throws Exception {
listenerCoursesListItemService.adapterShowLayoutTransparent();
}
})
.doFinally(new Action() {
@Override
public void run() throws Exception {
listenerCoursesListItemService.adapterHideLayoutTransparent();
}
})
.subscribeWith(new DisposableObserver<String>() {
@Override
public void onComplete() {
notifyDataSetChanged();
}
@Override
public void onError(Throwable e) {
Throwable t = new Throwable(e).fillInStackTrace();
FirebaseCrash.report(t);
}
@Override
public void onNext(String string) {
}
}));
}
}
答案 0 :(得分:0)
尝试
return Observable.defer(new Callable<ObservableSource<? extends String>>() {
@Override
public ObservableSource<? extends String> call() throws Exception {
if (shortTermCoursesModels != null && !shortTermCoursesModels.isEmpty()) {
Iterator<GetShortTermCoursesModel> lst = shortTermCoursesModels.iterator();
while (lst.hasNext()) {
GetShortTermCoursesModel values = lst.next();
if (mCompositeDisposable.isDisposed()) return Observable.just("Stop");
if(values.getCourseCategoryId()!=null){
if (idServer.compareTo(Integer.parseInt(values.getCourseCategoryId())) == 0) {
lst.remove();
}
}
}
}
return Observable.just("Finish");
}
});