Skip to content

Smarter position provided by getPopupText(position) #11

@herbeth1u

Description

@herbeth1u

Actual Behavior

I implemented in my app a fullscreen RecyclerView with getPopupText support. It looks like this:

The problem is, the position provided by getPopupText is the first visible item in the Adapter. Though as you can see here, this item (framed in red) is actually barely visible. So while the user only sees items starting with "L", the popup still shows "K", because the very last "K" item still hasn't been recycled.

I was thinking maybe there is a smarter way than getFirstItemAdapterPosition() to get this position.
As I'm a bit curious, I investigated how other fast scrollers handle this issue. For instance, Nova Launcher's widget list uses a fast scroll which applies some kind of padding to this position, proportional to how low you are in the list (the more you scroll, the lower the item targeted by getPopupText is on the screen). Which enables their popup to use the very first item's position when you're at the top, the very last item's position when you're at the bottom, and the position of an item which is always visible when you're anywhere in between.

It's kinda hard to explain with words. Actually experimenting with it helps to understand.
I am also aware that the Google Contacts app works in a similar way (using the first visible item), though it's not a problem because their list is not full screen, and the list snaps when fast scrolling, to make sure the first item is always fully visible. Not all lists can mimic this behavior though.

Expected Behavior

The position provided by getPopupText should target an item which is always (clearly) visible to the user.

Steps to Reproduce the Problem

  1. Create a RecyclerView and simply bind a FastScroller with FastScrollerBuilder(recyclerView).build() (the issue is more visible with a full screen RV).
  2. Implement PopupTextProvider in the Adapter.
  3. Scroll.

Specifications

  • Version: v1.1.0
  • Platform: Android 10, OnePlus 6 OxygenOS 10.3.1, no root

Don't hesitate to ask for more details if it wasn't clear. :)
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions