Closed yangsuni1024 closed 4 years ago
If you are using a loading row (which is set by default) then your source adapter will be wrapped with WrapperAdapter
.
The issue that you are mentioning is related to this architectural decision. Your source adapter is not directly attached and observed by RecyclerView
- the WrapperAdapter
is.
That leads to immediate attaching and then detaching from RecyclerView which you can see in the logs e.g.:
paginate D/MyAdapter: onAttachedToRecyclerView
paginate D/MyAdapter: onDetachedFromRecyclerView
If you do not use the loading row this won't be the case since your source adapter won't be wrapped. You can set up like following:
Paginate.with(recyclerView, this)
.addLoadingListItem(false)
.build();
Next, that will be released soon will propagate attach/detach call from WrapperAdapter to the source adapter but this won't completely solve the issue since the adapter will be:
By doing so you will have a proper state that the adapter is actually "attached" but this but the glitch could be that you see one iteration of detaching then attaching when Paginate is setup. Depending on what you are doing in these callbacks this might or might not be an issue for you.
In logs you will see something like:
paginate D/MyAdapter: onAttachedToRecyclerView
paginate D/MyAdapter: onDetachedFromRecyclerView
paginate D/MyAdapter: onAttachedToRecyclerView
And when paginate.unbind()
is called, source adapter is swapped back to RecyclerView
so calls will be:
paginate D/MyAdapter: onDetachedFromRecyclerView
paginate D/MyAdapter: onAttachedToRecyclerView
The solution mentioned in the comment above has been implemented in the latest release (check release 1.0.0)
I'm closing this issue for now, feel free to reopen it with API suggestion for solving this problem or better yet pull request.
My RecyclerViewAdapter used onAttachedToRecyclerView and onDetachedFromRecyclerView Method.
But WrapperAdapter in RecyclerPaginate not called it.