library: add fast-scroller
Add a fast-scroller to the library view. This makes long lists of items such as albums easier to scroll through, but also requires pre-sorting of artists to make sure that unintended behavior does not occur. A future commit may improve the sort options here so that this does not need to occur.
This commit is contained in:
parent
7adfb921fa
commit
5131db5383
4 changed files with 27 additions and 3 deletions
|
@ -17,6 +17,7 @@ import org.oxycblt.auxio.music.Artist
|
|||
import org.oxycblt.auxio.music.Genre
|
||||
import org.oxycblt.auxio.music.Parent
|
||||
import org.oxycblt.auxio.music.Song
|
||||
import org.oxycblt.auxio.recycler.sliceArticle
|
||||
import org.oxycblt.auxio.ui.getSpans
|
||||
import org.oxycblt.auxio.ui.newMenu
|
||||
|
||||
|
@ -67,6 +68,13 @@ class LibraryFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
binding.libraryFastScroll.setup(binding.libraryRecycler) { pos ->
|
||||
val item = libraryModel.libraryData.value!![pos]
|
||||
val char = item.displayName.sliceArticle().first().uppercaseChar()
|
||||
|
||||
if (char.isDigit()) '#' else char
|
||||
}
|
||||
|
||||
// --- VIEWMODEL SETUP ---
|
||||
|
||||
libraryModel.libraryData.observe(viewLifecycleOwner) { data ->
|
||||
|
|
|
@ -11,6 +11,7 @@ import androidx.core.database.getStringOrNull
|
|||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.database.BlacklistDatabase
|
||||
import org.oxycblt.auxio.logD
|
||||
import org.oxycblt.auxio.recycler.SortMode
|
||||
|
||||
/**
|
||||
* Class that loads/constructs [Genre]s, [Artist]s, [Album]s, and [Song] objects from the filesystem
|
||||
|
@ -227,6 +228,9 @@ class MusicLoader(private val context: Context) {
|
|||
)
|
||||
}
|
||||
|
||||
// Make the artist view line up with the rest of the lists by sorting it.
|
||||
artists = SortMode.ALPHA_DOWN.getSortedArtistList(artists).toMutableList()
|
||||
|
||||
logD("Albums successfully linked into ${artists.size} artists")
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import kotlin.math.roundToInt
|
|||
* fast-scrollers, this one displays indicators and a thumb instead of simply a scroll bar.
|
||||
* 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: Make this update with data.
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
class FastScrollView @JvmOverloads constructor(
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".library.LibraryFragment">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
|
@ -13,6 +13,9 @@
|
|||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/library_toolbar"
|
||||
style="@style/Toolbar.Style"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:menu="@menu/menu_library"
|
||||
app:title="@string/label_library" />
|
||||
|
||||
|
@ -22,7 +25,17 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/library_toolbar"
|
||||
tools:listitem="@layout/item_artist" />
|
||||
|
||||
</LinearLayout>
|
||||
<org.oxycblt.auxio.songs.FastScrollView
|
||||
android:id="@+id/library_fast_scroll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/library_toolbar" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
Loading…
Reference in a new issue