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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user