Remove sub-item sorting
Remove the sorting of the music models child items, its mostly redundant for now.
This commit is contained in:
parent
6b56ce4ae8
commit
f5d007267d
5 changed files with 12 additions and 23 deletions
|
@ -35,9 +35,9 @@ fun ImageView.getCoverArt(album: Album) {
|
||||||
// Get the artist image
|
// Get the artist image
|
||||||
@BindingAdapter("artistImage")
|
@BindingAdapter("artistImage")
|
||||||
fun ImageView.getArtistImage(artist: Artist) {
|
fun ImageView.getArtistImage(artist: Artist) {
|
||||||
// If there are more than one albums, then create a mosaic of them.
|
|
||||||
val request: ImageRequest
|
val request: ImageRequest
|
||||||
|
|
||||||
|
// If there are more than one albums, then create a mosaic of them.
|
||||||
if (artist.numAlbums >= 4) {
|
if (artist.numAlbums >= 4) {
|
||||||
val uris = mutableListOf<Uri>()
|
val uris = mutableListOf<Uri>()
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,4 @@ data class Album(
|
||||||
|
|
||||||
val songs = mutableListOf<Song>()
|
val songs = mutableListOf<Song>()
|
||||||
val numSongs: Int get() = songs.size
|
val numSongs: Int get() = songs.size
|
||||||
|
|
||||||
fun finalize() {
|
|
||||||
songs.sortBy { it.track }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,16 +10,17 @@ data class Artist(
|
||||||
var genre = ""
|
var genre = ""
|
||||||
|
|
||||||
val numAlbums: Int get() = albums.size
|
val numAlbums: Int get() = albums.size
|
||||||
var numSongs = 0
|
val numSongs: Int get() {
|
||||||
|
var num = 0
|
||||||
fun finalize() {
|
albums.forEach {
|
||||||
albums.sortByDescending { it.year }
|
num += it.numSongs
|
||||||
|
|
||||||
albums.forEach { album ->
|
|
||||||
numSongs += album.numSongs
|
|
||||||
}
|
}
|
||||||
|
return num
|
||||||
|
}
|
||||||
|
|
||||||
// If the artist has more than one genre, pick the most used one.
|
fun finalizeGenre() {
|
||||||
|
// If the artist has more than one genre, pick the most "prominent" one.
|
||||||
|
// [Really just eliminate duplicates created from my hacky way of getting genres loaded but shhhh]
|
||||||
genre = if (genres.size > 1) {
|
genre = if (genres.size > 1) {
|
||||||
val groupGenres = genres.groupBy { it.name }
|
val groupGenres = genres.groupBy { it.name }
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,4 @@ data class Genre(
|
||||||
var name: String,
|
var name: String,
|
||||||
) {
|
) {
|
||||||
val artists = mutableListOf<Artist>()
|
val artists = mutableListOf<Artist>()
|
||||||
|
|
||||||
fun finalize() {
|
|
||||||
artists.sortByDescending { it.name }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,12 +146,8 @@ class MusicSorter(
|
||||||
|
|
||||||
// Finalize music
|
// Finalize music
|
||||||
private fun finalizeMusic() {
|
private fun finalizeMusic() {
|
||||||
// Correct any empty names [""] with the proper placeholders [Unknown Album]
|
// Finalize the genre for each artist
|
||||||
genres.forEach { it.finalize() }
|
artists.forEach { it.finalizeGenre() }
|
||||||
|
|
||||||
artists.forEach { it.finalize() }
|
|
||||||
|
|
||||||
albums.forEach { it.finalize() }
|
|
||||||
|
|
||||||
// Then finally sort the music
|
// Then finally sort the music
|
||||||
genres.sortWith(
|
genres.sortWith(
|
||||||
|
|
Loading…
Reference in a new issue