avluis / Hentoid

Doujinshi Android App
https://discord.gg/QEZ3qk9
Apache License 2.0
1.07k stars 83 forks source link

Queue screen - Add a fast scroller #488

Closed RobbWatershed closed 4 years ago

RobbWatershed commented 4 years ago

...mainly to help users with a huge queue.

wightwulf1944 commented 4 years ago

Simply adding a scrollbar is very easy and can be done in xml like below.

<android.support.v7.widget.RecyclerView
      ...
      android:scrollbars="vertical" />

But this only shows a scrollbar that shows the current scroll position, it cannot be touched or dragged to scroll through content. To add a scrollbar that can be dragged to scroll through content, fastScrollEnabled=true needs to be added to the RecyclerView along with a few drawables for the scrollbar itself.

https://stackoverflow.com/questions/45370246/how-to-use-fastscrollenabled-in-recyclerview

The process is a little bit more involved than simply turning scrollbars on and while some libraries exist to implement this, they don't usually play well with other recyclerview helpers because they require you to use their own RecyclerView and Adapter subclass.

https://github.com/timusus/RecyclerView-FastScroll

Usually the best solution is to follow the stackoverflow guide above and create a subclass of RecyclerView which overrides computeVerticalScrollExtent(), computeVerticalScrollOffset(), and computeVerticalScrollRange() so that the scrollbar doesn't become too small in very long lists.

RobbWatershed commented 4 years ago

Also consider https://github.com/mikepenz/FastAdapter/issues/1 => https://github.com/plusCubed/recycler-fast-scroll