Resolve fast-scroll resource issues

Accidentally forgot to move the resources from the fast scroll library, so here it is.
This commit is contained in:
OxygenCobalt
2021-03-22 16:17:16 -06:00
parent 02fed16c31
commit ffd3275ca5
6 changed files with 65 additions and 10 deletions
@@ -20,8 +20,9 @@ import org.oxycblt.auxio.ui.inflater
/**
* The companion thumb for [FastScrollView]. This does not need any setup, instead pass it as an
* argument to [FastScrollView.setup].
* This code is fundamentally an adaptation of Reddit's IndicatorFastScroll, targeted towards
* Auxio specifically. Check them out here: https://github.com/reddit/IndicatorFastScroll/
* This code is fundamentally an adaptation of Reddit's IndicatorFastScroll, albeit specialized
* towards Auxio. The original library is here: https://github.com/reddit/IndicatorFastScroll/
* TODO: Merge this view and FastScrollView? They are effectively reliant on eachother
* @author OxygenCobalt
*/
class FastScrollThumb @JvmOverloads constructor(
@@ -70,7 +71,7 @@ class FastScrollThumb @JvmOverloads constructor(
/**
* Make the thumb jump to a new position and update its text to the given [indicator].
* This is not meant for use outside of the main [FastScrollView] code, don't use it.
* This is not meant for use outside of the main [FastScrollView] code. Do not use it.
*/
fun jumpTo(indicator: FastScrollView.Indicator, centerY: Int) {
binding.thumbText.text = indicator.char.toString()
@@ -24,8 +24,8 @@ import kotlin.math.min
/**
* A view that allows for quick scrolling through a [RecyclerView] with many items. Unlike other
* fast-scrollers, this one displays indicators instead of simply a scroll bar.
* This code is fundamentally an adaptation of Reddit's IndicatorFastScroll, targeted towards
* Auxio specifically. Check them out here: https://github.com/reddit/IndicatorFastScroll/
* This code is fundamentally an adaptation of Reddit's IndicatorFastScroll, albeit specialized
* towards Auxio. The original library is here: https://github.com/reddit/IndicatorFastScroll/
* @author OxygenCobalt
*/
class FastScrollView @JvmOverloads constructor(
@@ -172,6 +172,7 @@ class FastScrollView @JvmOverloads constructor(
}
if (touchY in (indicatorText.top until indicatorText.bottom)) {
// Try to roughly caculate which indicator the user is currently touching [Since the
val textHeight = indicatorText.height / indicators.size
val indicatorIndex = min(
(touchY - indicatorText.top) / textHeight, indicators.lastIndex