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.

[PagingWithNetworkSample] Scroll position is offset when loading completes

See original GitHub issue

This is an issue I’ve seen in my own project and so I checked out how it is done here and I’m seeing the same bug. When loading the data for the first time using the DB + Network option, the scroll bar is not at the top when loading finishes, but partway down the screen. How can we keep the scroll position stuck to the top while loading? With a large dataset this is more obvious and it’s not a great experience.

See recording here: https://drive.google.com/open?id=1OwT87Gj5BeGz-ld_fIyQaIJvfz_49Tut

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
astr0-4commented, Nov 2, 2019

Thanks for the fix @dlam! It turns out the issue in my app was because the app’s sort order was different than the sort order of the data from the network. Thanks to you and the guys at dev summit for helping me resolve this bug 🙌 🙌

0reactions
dlamcommented, Oct 29, 2019

So it seems the issue is that RecyclerView is using the loading spinner as an anchor during initial load since Paging gives it an initial empty list + spinner, while it’s waiting for the initialLoad to complete, which then completes with initial page + spinner.

There’s a workaround here #751 - thanks for reporting the issue!

Another way to fix this would be to actually send a AsyncDiffer update to remove the spinner before loading in the initial page or to prevent the differ from ever successfully comparing the spinner.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Paging 3 - experiencing flickers, glitches or jumps in ...
By default, Room's PagingSource picks an index based on last bound position and offsets based on pageSize . In order for refresh to...
Read more >
Wrong scroll position if page is loaded when ... - Issue Tracker
Discovered a bug where the scroll position is not preserved when page data is loaded outside visible area while only the placeholders are...
Read more >
Source Code for PagedList.java - AndroidX Tech
<p> * PagedList can present data for an unbounded, infinite scrolling list, ... are * loaded or dropped) and fast-scrolling to any position,...
Read more >
error: rendered more hooks than during the previous render.
Examine which components are taking more time to load. ... function that will be executed once setState is completed and the component is...
Read more >
Can you properly restore the RecyclerView scroll position ...
When state is saved, layout manager saves whatever necessary (e.g. for `LinearLayoutManager`, it is the top item's position + offset from anchor ...
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