From 8a70ece442f93d21e53fd254c9c5dde1c18c11f2 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Fri, 2 Sep 2022 20:13:47 -0600 Subject: [PATCH] recycler: fix fast scroll issues Fix issues with the fast scroller, such as an improper thumb position and strange item behavior stemming from dataset changes. --- .../oxycblt/auxio/ui/fastscroll/FastScrollRecyclerView.kt | 2 +- app/src/main/res/drawable/ui_item_ripple.xml | 5 +++++ app/src/main/res/layout/item_album_song.xml | 2 +- app/src/main/res/layout/item_parent.xml | 2 +- app/src/main/res/layout/item_song.xml | 2 +- app/src/main/res/values/dimens.xml | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/drawable/ui_item_ripple.xml diff --git a/app/src/main/java/org/oxycblt/auxio/ui/fastscroll/FastScrollRecyclerView.kt b/app/src/main/java/org/oxycblt/auxio/ui/fastscroll/FastScrollRecyclerView.kt index 5c5ee74b4..1721fde0e 100644 --- a/app/src/main/java/org/oxycblt/auxio/ui/fastscroll/FastScrollRecyclerView.kt +++ b/app/src/main/java/org/oxycblt/auxio/ui/fastscroll/FastScrollRecyclerView.kt @@ -291,7 +291,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr } private fun updateScrollbarState() { - if (computeVerticalScrollRange() <= height || childCount == 0) { + if (scrollRange <= height || childCount == 0) { return } diff --git a/app/src/main/res/drawable/ui_item_ripple.xml b/app/src/main/res/drawable/ui_item_ripple.xml new file mode 100644 index 000000000..03fd102f4 --- /dev/null +++ b/app/src/main/res/drawable/ui_item_ripple.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_album_song.xml b/app/src/main/res/layout/item_album_song.xml index 7df576ac0..8b5db7121 100644 --- a/app/src/main/res/layout/item_album_song.xml +++ b/app/src/main/res/layout/item_album_song.xml @@ -5,7 +5,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackground" + android:background="@drawable/ui_item_ripple" android:paddingTop="@dimen/spacing_medium" android:paddingBottom="@dimen/spacing_medium" android:paddingEnd="@dimen/spacing_mid_medium" diff --git a/app/src/main/res/layout/item_parent.xml b/app/src/main/res/layout/item_parent.xml index 808af6af2..32df8e2b0 100644 --- a/app/src/main/res/layout/item_parent.xml +++ b/app/src/main/res/layout/item_parent.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackground" + android:background="@drawable/ui_item_ripple" android:paddingTop="@dimen/spacing_medium" android:paddingBottom="@dimen/spacing_medium" android:paddingEnd="@dimen/spacing_mid_medium" diff --git a/app/src/main/res/layout/item_song.xml b/app/src/main/res/layout/item_song.xml index e23cc8be7..89911731c 100644 --- a/app/src/main/res/layout/item_song.xml +++ b/app/src/main/res/layout/item_song.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackground" + android:background="@drawable/ui_item_ripple" android:paddingTop="@dimen/spacing_medium" android:paddingBottom="@dimen/spacing_medium" android:paddingEnd="@dimen/spacing_mid_medium" diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 61c79cf8a..5b705f331 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -41,7 +41,7 @@ 64dp @dimen/spacing_medium 28dp - 16dp + 48dp 6dp