Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we call next page with Paging Module to load without scrolling #41

Closed
palVikas9 opened this issue May 14, 2021 · 5 comments
Closed
Labels

Comments

@palVikas9
Copy link

Hi @ironsrc,

Thanks for the library. Have been using it quite a number of my projects but have recently ran into a problem that the API response has only 10 items and the UI doesn't cover whole page and due to that the scroll event of recyclerview is not called.

Is there any way or function can make the Paging module load the next page without scrolling.

Any help would be appreciated.

@idanatz
Copy link
Collaborator

idanatz commented May 14, 2021

Hi @palVikas9
can you share the paging module definition?
please expand on the scenario, what's the current behavior and your expected behavior
is it a bug or an API functionality addition - to be able to call the load page without scrolling?
Thanks

@palVikas9
Copy link
Author

palVikas9 commented May 15, 2021

Hi @idanatz ,

Yeah, sure.

inner class PagingModuleImpl : PagingModule() { init { config { layoutResource = R.layout.layout_progress_bar visibleThreshold = 4 } onLoadMore { currentPage -> profileDetailViewModel.postPage = currentPage + 1 profileDetailViewModel.callGetUserPostAPI(selfUserId, profileDetailViewModel.postPage) } } }

It is a functionality that when I get the response from API call for page 1, then API call for the page 2 should be trigged by PagingModule of oneAdapter without scrolling of the recyclerview.

Right now, is there any existing way that we can do that ?`

@idanatz
Copy link
Collaborator

idanatz commented May 16, 2021

You are right, it's a bug and will be fixed in the next version - the onLoad will be triggered automatically when the conditions for paging are met after each data submission.

Regarding a quick-fix,
I haven't found a way around it... since the RecyclerView is not scrollable in this usecase, the scroll listener is not being invoked in any programmatically way I tried.

But, you can try and trigger your logic manually when detecting this usecase by using the getVisibleItems() and verifing it's the same number as Items you got in your API response.
It's not the cleanest way and you won't get the currentPage param but from your description its safe to assume its happening in the first API response so it will be 1.

@idanatz idanatz added resolved in the next version bug Something isn't working labels May 16, 2021
@palVikas9
Copy link
Author

Thanks.

For the time being, I have added a workaround in my code.

If the condition for next api call is satisfied then it is called and in the loadmore, I call currentPage+2 instead of 1.

It is a lovely library to work with. Have made my life so much easier.

@idanatz
Copy link
Collaborator

idanatz commented May 17, 2021

Thanks for the kind words!
a fix has been released with v2.1.1, check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants