loadAfter()也无法停止。 它一直在调用onBindView-> loadAfter()
我尝试调试,找到以下这些: 类 ContiguousPagedList
中的方法 loadAroundInternalint appendItems = getAppendItemsRequested(mConfig.prefetchDistance, index, mStorage.getLeadingNullCount() + mStorage.getStorageCount());
索引保留++,而recyclerView中的 getBindView 更大 appendItem 始终为> 0
我不确定,但我想也许
network->appendPage->notifyInserted->bindView->loadAfter->network
然后recyclerView适配器在onBindView上执行。但是不应调用哪个位置的bindViewHolder。所以它不能停止。
我不知道我是否正确,也不知道如何解决。
下面是我写的一些相关代码:
@Override
public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
VB binding = DataBindingUtil.getBinding(holder.itemView);
setData(binding, getItem(position));
binding.executePendingBindings();
}
在我自己的 PagingDataSource 中,该扩展了 PageKeyedDataSource
@Override
public void loadAfter(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, T> callback) {
singleCreator.createSingle(params.key, params.requestedLoadSize)
.subscribe(new SingleObserver<Page<T>>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSuccess(Page<T> tPage) {
callback.onResult(tPage.list, tPage.pageNumber + 1);
}
@Override
public void onError(Throwable e) {
}
});
}
public interface SingleCreator<T> {
SingleSubscribeProxy<Page<T>> createSingle(int page, int pageSize);
}
如果有其他需要,我将编辑问题
====================================
添加消息:我发现是否为recyclerView的高度设置了绝对值,例如100dp,它可以正常工作。但是在wrap_content和match_parent时出现问题。
所以现在的问题是:当在nestedScrollView中有2个recyclerViews并带有wrap_content或match_parent时,bindView无法停止分页库方法之一的loadAfter()。
答案 0 :(得分:0)
所以它发生的原因 当网络结果返回时,recycleView刷新。 由于它位于nestedScrollView中,因此没有确切的高度。 然后onSizeChanged-> getItem-> network。
对我来说,解决方案是 编写一个实现 NestedScrollingParent2 的自定义linearLayout;