Fixed fast scroll text layout

closes #278
This commit is contained in:
Jay 2020-05-04 15:32:01 -04:00
parent c565898599
commit d3584fcc4f

View File

@ -174,14 +174,21 @@ class LibraryController(
setActiveCategory() setActiveCategory()
if (presenter.categories.size > 1 && dy != 0) { if (presenter.categories.size > 1 && dy != 0) {
val headerItem = getHeader() ?: return val headerItem = getHeader() ?: return
val view = fast_scroller?.getChildAt(0) ?: return val view = fast_scroller ?: return
val height = if (view.childCount > 0) {
view.height - (view.getChildAt(0)?.paddingTop ?: 0) -
(view.getChildAt(view.childCount - 1)?.paddingBottom ?: 0)
} else {
view.height
}
val index = adapter.headerItems.indexOf(headerItem) val index = adapter.headerItems.indexOf(headerItem)
textAnim?.cancel() textAnim?.cancel()
textAnim = text_view_m.animate().alpha(0f).setDuration(250L).setStartDelay(2000) textAnim = text_view_m.animate().alpha(0f).setDuration(250L).setStartDelay(2000)
textAnim?.start() textAnim?.start()
// fastScroll height * indicator position - center text - fastScroll padding // fastScroll height * indicator position - center text - fastScroll padding
text_view_m.translationY = view.height * text_view_m.translationY = height *
(index.toFloat() / (adapter.headerItems.size + 1)) (index.toFloat() / (adapter.headerItems.size + 1))
- text_view_m.height / 2 + 16.dpToPx - text_view_m.height / 2 + 16.dpToPx
text_view_m.translationX = 45f.dpToPxEnd text_view_m.translationX = 45f.dpToPxEnd