question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onItemAtEndLoaded not always called

See original GitHub issue

I’m using the PagingNetworkExample (room + network) where onItemAtEndLoaded is not called when i fast scroll down the list and to make it load more data from the network i have to scroll up a little and scroll back down.

This is my list:

        val config = PagedList.Config.Builder()
                .setPageSize(20)
                .setInitialLoadSizeHint(20)
//                .setPrefetchDistance(10)
                .setEnablePlaceholders(false)
                .build()

        runBlocking {

            moviesList = LivePagedListBuilder(
                    CinemaDatabase.getInstance(application)
                            .popularMoviesDao()
                            .getMoviesDataSource(), config)
                    .setBackgroundThreadExecutor(BackgroundThreadExecutor())
                    .setBoundaryCallback(PopularMoviesBoundaryCallback(application))
                    .build()
        }

The Room part:

     @Query(...)
    fun getMoviesDataSource(): DataSource.Factory<Int, MoviesEntity>

The BoundaryCallback:

class PopularMoviesBoundaryCallback(val context: Context) : PagedList.BoundaryCallback<MoviesEntity>() {

    override fun onZeroItemsLoaded() = SyncUtils.initialize(context)

    override fun onItemAtEndLoaded(itemAtEnd: MoviesEntity) {

        val prefs = defaultPrefs(context)

        fetchPopularMoviesData(context = context, page = prefs[KEY_PAGE_POPULAR, 1] + 1)

        prefs[KEY_PAGE_POPULAR] = prefs[KEY_PAGE_POPULAR, 1] + 1
    }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fxmeistercommented, Mar 21, 2018

@msayan Did changing placeholders help you? I think this bug is related to the paging library, as the link you provided claims to have been fixed on Jan 18th, 2018, but we are experiencing this bug with the latest provided code sample, still.

0reactions
dlamcommented, Feb 9, 2021

Thanks for all the replies here - appreciate filing against our issuetracker as well. As noted in the bug, this v2 api has been superseded by RemoteMediator in v3, so I don’t really anticipate fixes as there is still a lot to do and realistically this won’t make it before v3 goes stable 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

onItemAtEndLoaded not always called · Issue #307 - GitHub
I'm using the PagingNetworkExample (room + network) where onItemAtEndLoaded is not called when i fast scroll down the list and to make it ......
Read more >
OnItemAtEndLoaded() called infinitely even when not at ...
In my implementation of Android paging library 2.0, the OnItemAtEndLoaded() is called numerous times even when not scrolled to the bottom of ...
Read more >
PagedList.BoundaryCallback - Android Developers
If for example onItemAtEndLoaded(Object) triggers a network load, ... Keys are not known because the BoundaryCallback is independent of the ...
Read more >
OnItemAtEndLoaded called only once [135966530]
After it loads new items, when you scroll down to the end of the page, it will not be called again. Here is...
Read more >
OnItemAtEndLoaded() called infinitely even when not at ...
[Solved]-OnItemAtEndLoaded() called infinitely even when not at bottom of list-kotlin. Search. score:0. Apparently this was an issue with my recycler view ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found