maltaisn/another-notes-app

[Bug] Empty space at the top of the RecyclerView

Closed this issue · 4 comments

This is a weird one and steps to reproduce are quite complex.

Steps to Reproduce

  1. Make sure that the recycle bin (deleted notes) is empty
  2. Create notes until all of them don't fit on the screen at once (until the recyclerview becomes scrollable) and pin at least one note
    image
  3. Scroll all the way to the bottom
    image
  4. Open the navigation drawer and go to 'Deleted'
  5. Go back to the regular notes view
    image
  6. Scroll all the way to the top
    image

Notice the additional empty space on the top above the 'Pinned' header.

Possible Fix

I have managed to fix this issue by re-creating the StaggeredGridLayoutManager every time after hiding the placeholderGroup within the placeholderData observer in NoteFragment.kt. This seems incredibly unnecessary and I'm sure there is a better way to fix this.

I am going to create a PR with my solution, but if you have a better idea on how to solve this issue, feel free to close that.

Can't reproduce it, they probably broke something in a newer Android version. StaggeredGridLayoutManager always had some annoying bugs... I'll merge it.

Actually the fix causes relayout when you select notes which creates an annoying flash. I'm also not sure this is the right solution, but I can't find a better one since I can't reproduce it. This is relatively minor and definitely not the worst bug about StaggeredGridLayoutManager so I wouldn't worried about it. For example it can't get its layout right and moves around all the time: https://stackoverflow.com/questions/61546213 and I never managed to fix that.

Yes, that was an oversight on my part. updatePlaceholder is called everytime listItems is set within the NoteViewModel. This caused the LayoutManager to also be recreated when selecting notes. I'll update the PR.

It also seems to only be reproducible on API Levels >= 31. This is definitely a weird one.