loadAfter() can't stop even though I didn't swipe the RecyclerView. It keeps calling onBindView->loadAfter()
I tried to debug, find these: method loadAroundInternal in class ContiguousPagedList
int appendItems = getAppendItemsRequested(mConfig.prefetchDistance, index, mStorage.getLeadingNullCount() + mStorage.getStorageCount());
index keep ++ while getBindView in recyclerView is being bigger the appendItem is always >0
I'm not sure, but I think maybe
network->appendPage->notifyInserted->bindView->loadAfter->network
then the recyclerView adapter execute onBindView.But the bindViewHolder which position should't call called. So it can't stop.
I don't know whether I'm right or not.And I don't know how to fix it.
below are some relevant code I wrote:
@Override
public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
VB binding = DataBindingUtil.getBinding(holder.itemView);
setData(binding, getItem(position));
binding.executePendingBindings();
}
In my own PagingDataSource which extends 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);
}
If other things need, I will edit the question
=====================================
Add message:I found if I set an absolute value for recyclerView's height, such as 100dp, It works fine. Butwork with problem when wrap_content and match_parent.
So the problem now is:when 2 recyclerViews in nestedScrollView and with a wrap_content or match_parent, the bindView can't stop loadAfter() which is a method of paging library.