static fixes
This commit is contained in:
parent
446fdcccb6
commit
2c56dd4ca4
|
|
@ -37,10 +37,12 @@ public class ObservableList<TItem> extends ObservableCollection<TItem> {
|
|||
private final List<TItem> items;
|
||||
|
||||
public ObservableList() {
|
||||
super();
|
||||
items = new ArrayList<>();
|
||||
}
|
||||
|
||||
public ObservableList(@NonNull final Collection<TItem> initialItems) {
|
||||
super();
|
||||
items = new ArrayList<>(initialItems);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public class LoadingGrowingList<TItemId, TItem extends ItemWithId<TItemId>>
|
|||
private final ObservableList<TItem> innerList = new ObservableList<>();
|
||||
|
||||
public LoadingGrowingList(@NonNull final LoadingRequestCreator<TItem, TItemId> loadingMoreRequestCreator) {
|
||||
super();
|
||||
this.loadingMoreRequestCreator = loadingMoreRequestCreator;
|
||||
innerList.observeChanges().subscribe(change -> {
|
||||
//do not change - bug of RetroLambda
|
||||
|
|
@ -64,6 +65,11 @@ public class LoadingGrowingList<TItemId, TItem extends ItemWithId<TItemId>>
|
|||
return innerList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Observable<Boolean> observeHaveMoreItems() {
|
||||
return haveMoreItems.distinctUntilChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Observable<?> getLoadMoreObservable() {
|
||||
return Observable
|
||||
|
|
@ -75,12 +81,11 @@ public class LoadingGrowingList<TItemId, TItem extends ItemWithId<TItemId>>
|
|||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(scheduler)
|
||||
.single()
|
||||
.onErrorResumeNext(throwable -> {
|
||||
.doOnError(throwable -> {
|
||||
if ((throwable instanceof IllegalArgumentException)
|
||||
|| (throwable instanceof NoSuchElementException)) {
|
||||
Lc.assertion("Updates during loading not supported. LoadingRequestCreator should emit only one result.");
|
||||
}
|
||||
return Observable.error(throwable);
|
||||
})
|
||||
.doOnNext(loadedItems -> {
|
||||
loadingMoreConcreteObservable = null;
|
||||
|
|
@ -123,8 +128,8 @@ public class LoadingGrowingList<TItemId, TItem extends ItemWithId<TItemId>>
|
|||
subscriber.onCompleted();
|
||||
})
|
||||
.subscribeOn(scheduler))
|
||||
.retryWhen(attempts ->
|
||||
attempts.map(throwable -> throwable instanceof DoRetryException ? Observable.just(null) : Observable.error(throwable)));
|
||||
.retryWhen(attempts -> attempts
|
||||
.switchMap(throwable -> throwable instanceof DoRetryException ? Observable.just(null) : Observable.error(throwable)));
|
||||
}
|
||||
|
||||
private static class DoRetryException extends Exception {
|
||||
|
|
|
|||
Loading…
Reference in New Issue