Fix sorting modes

Change the NUMERIC_DOWN sorting mode to actually sort by decending order, not ascending order.
This commit is contained in:
OxygenCobalt 2020-09-24 06:59:53 -06:00
parent 414e85153f
commit ac3b3e7903
19 changed files with 77 additions and 81 deletions

View file

@ -9,11 +9,11 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import org.oxycblt.auxio.reycler.ClickListener
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.FragmentAlbumDetailBinding
import org.oxycblt.auxio.detail.adapters.DetailSongAdapter
import org.oxycblt.auxio.music.MusicViewModel
import org.oxycblt.auxio.recycler.ClickListener
import org.oxycblt.auxio.theme.applyDivider
class AlbumDetailFragment : Fragment() {

View file

@ -9,14 +9,13 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import org.oxycblt.auxio.reycler.ClickListener
import org.oxycblt.auxio.databinding.FragmentArtistDetailBinding
import org.oxycblt.auxio.detail.adapters.DetailAlbumAdapter
import org.oxycblt.auxio.music.MusicViewModel
import org.oxycblt.auxio.music.models.Album
import org.oxycblt.auxio.reycler.SortMode
import org.oxycblt.auxio.recycler.ClickListener
import org.oxycblt.auxio.recycler.SortMode
import org.oxycblt.auxio.theme.applyDivider
import java.util.Comparator
class ArtistDetailFragment : Fragment() {

View file

@ -1,12 +1,11 @@
package org.oxycblt.auxio.detail
import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import org.oxycblt.auxio.music.models.Album
import org.oxycblt.auxio.music.models.Artist
import org.oxycblt.auxio.reycler.SortMode
import org.oxycblt.auxio.recycler.SortMode
class DetailViewModel : ViewModel() {
var isAlreadyNavigating = false

View file

@ -4,14 +4,14 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.reycler.ClickListener
import org.oxycblt.auxio.databinding.ItemAlbumBinding
import org.oxycblt.auxio.music.models.Album
import org.oxycblt.auxio.reycler.DiffCallback
import org.oxycblt.auxio.recycler.ClickListener
import org.oxycblt.auxio.recycler.DiffCallback
class DetailAlbumAdapter(
private val listener: ClickListener<Album>
) : ListAdapter<Album, DetailAlbumAdapter.ViewHolder>(DiffCallback()){
) : ListAdapter<Album, DetailAlbumAdapter.ViewHolder>(DiffCallback()) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(

View file

@ -3,9 +3,9 @@ package org.oxycblt.auxio.detail.adapters
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.reycler.ClickListener
import org.oxycblt.auxio.databinding.ItemAlbumSongBinding
import org.oxycblt.auxio.music.models.Song
import org.oxycblt.auxio.recycler.ClickListener
class DetailSongAdapter(
private val data: List<Song>,

View file

@ -8,12 +8,12 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import org.oxycblt.auxio.reycler.ClickListener
import org.oxycblt.auxio.MainFragmentDirections
import org.oxycblt.auxio.databinding.FragmentLibraryBinding
import org.oxycblt.auxio.library.adapters.ArtistAdapter
import org.oxycblt.auxio.music.MusicViewModel
import org.oxycblt.auxio.music.models.Artist
import org.oxycblt.auxio.recycler.ClickListener
import org.oxycblt.auxio.theme.applyDivider
class LibraryFragment : Fragment() {

View file

@ -3,9 +3,9 @@ package org.oxycblt.auxio.library.adapters
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.reycler.ClickListener
import org.oxycblt.auxio.databinding.ItemAlbumBinding
import org.oxycblt.auxio.music.models.Album
import org.oxycblt.auxio.recycler.ClickListener
class AlbumAdapter(
private val data: List<Album>,

View file

@ -3,9 +3,9 @@ package org.oxycblt.auxio.library.adapters
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.reycler.ClickListener
import org.oxycblt.auxio.databinding.ItemArtistBinding
import org.oxycblt.auxio.music.models.Artist
import org.oxycblt.auxio.recycler.ClickListener
class ArtistAdapter(
private val data: List<Artist>,

View file

@ -86,7 +86,6 @@ fun TextView.bindArtistCounts(artist: Artist) {
text = context.getString(R.string.format_double_counts, albums, songs)
}
// Get the artist genre.
// TODO: Stub, add option to list all genres instead of just the most prominent
@BindingAdapter("artistGenre")

View file

@ -10,7 +10,8 @@ data class Artist(
var genre = ""
val numAlbums: Int get() = albums.size
val numSongs: Int get() {
val numSongs: Int
get() {
var num = 0
albums.forEach {
num += it.numSongs

View file

@ -1,9 +1,8 @@
package org.oxycblt.auxio.reycler
package org.oxycblt.auxio.recycler
import androidx.recyclerview.widget.DiffUtil
import org.oxycblt.auxio.R
import org.oxycblt.auxio.music.models.Album
import org.oxycblt.auxio.music.models.Artist
// RecyclerView click listener
class ClickListener<T>(val onClick: (T) -> Unit)
@ -32,8 +31,8 @@ enum class SortMode(val iconRes: Int) {
// Sort comparators are different for each music model, so they are
// static maps instead.
val albumSortComparators = mapOf<SortMode, Comparator<Album>>(
NUMERIC_DOWN to compareBy { it.year },
NUMERIC_UP to compareByDescending { it.year },
NUMERIC_DOWN to compareByDescending { it.year },
NUMERIC_UP to compareBy { it.year },
// Alphabetic sorting needs to be case-insensitive
ALPHA_DOWN to compareByDescending(

View file

@ -3,9 +3,9 @@ package org.oxycblt.auxio.songs
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.reycler.ClickListener
import org.oxycblt.auxio.databinding.ItemSongBinding
import org.oxycblt.auxio.music.models.Song
import org.oxycblt.auxio.recycler.ClickListener
class SongAdapter(
private val data: List<Song>,

View file

@ -7,9 +7,9 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import org.oxycblt.auxio.reycler.ClickListener
import org.oxycblt.auxio.databinding.FragmentSongsBinding
import org.oxycblt.auxio.music.MusicViewModel
import org.oxycblt.auxio.recycler.ClickListener
import org.oxycblt.auxio.theme.applyDivider
class SongsFragment : Fragment() {

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Divider used by recyclerview header items
https://stackoverflow.com/a/61157571/14143986
-->
@ -17,7 +16,6 @@ https://stackoverflow.com/a/61157571/14143986
<item>
<ripple
android:color="@color/selection_color"
android:radius="@dimen/divider_ripple_size">
</ripple>
android:radius="@dimen/divider_ripple_size"></ripple>
</item>
</layer-list>

View file

@ -7,13 +7,13 @@
<path
android:fillColor="#FF000000"
android:pathData="m3.6944,17.9917h-2.7188L5.1182,5.9917L8.3877,5.9917L12.5244,17.9917h-2.7188L6.7998,8.7339L6.7061,8.7339ZM3.5244,13.2749h6.4219v1.9805L3.5244,15.2554Z"
android:strokeWidth="0.4125"/>
android:strokeWidth="0.4125" />
<path
android:fillColor="#FF000000"
android:pathData="m13.8369,17.9917v-1.5059l5.9883,-8.4023h-6L13.8252,5.9917h9.1875L23.0127,7.4975L17.0185,15.8999h6.0059v2.0918z"
android:strokeWidth="0.4125"/>
android:strokeWidth="0.4125" />
<path
android:pathData="m15.5,20.5355c-2.3333,0 -4.6667,0 -7,0 1.1667,1.152 2.3333,2.304 3.5,3.456 1.1667,-1.152 2.3333,-2.304 3.5,-3.456z"
android:strokeWidth="0.139935"
android:fillColor="#000000"/>
android:fillColor="#000000" />
</vector>

View file

@ -7,13 +7,13 @@
<path
android:fillColor="#FF000000"
android:pathData="m3.6944,17.9917h-2.7188L5.1182,5.9917L8.3877,5.9917L12.5244,17.9917h-2.7188L6.7998,8.7339L6.7061,8.7339ZM3.5244,13.2749h6.4219v1.9805L3.5244,15.2554Z"
android:strokeWidth="0.4125"/>
android:strokeWidth="0.4125" />
<path
android:fillColor="#FF000000"
android:pathData="m13.8369,17.9917v-1.5059l5.9883,-8.4023h-6L13.8252,5.9917h9.1875L23.0127,7.4975L17.0185,15.8999h6.0059v2.0918z"
android:strokeWidth="0.4125"/>
android:strokeWidth="0.4125" />
<path
android:pathData="m15.5,3.4478c-2.3333,0 -4.6667,0 -7,0 1.1667,-1.152 2.3333,-2.304 3.5,-3.456 1.1667,1.152 2.3333,2.304 3.5,3.456z"
android:strokeWidth="0.139935"
android:fillColor="#000000"/>
android:fillColor="#000000" />
</vector>

View file

@ -7,13 +7,13 @@
<path
android:pathData="m15.5,20.544c-2.3333,0 -4.6667,0 -7,0 1.1667,1.152 2.3333,2.304 3.5,3.456 1.1667,-1.152 2.3333,-2.304 3.5,-3.456z"
android:strokeWidth="0.139935"
android:fillColor="#000000"/>
android:fillColor="#000000" />
<path
android:fillColor="#FF000000"
android:pathData="M6.5424,18.0001Q5.034,17.9945 3.9466,17.2836 2.865,16.5728 2.2804,15.2244 1.7016,13.876 1.7074,11.9804q0,-1.89 0.5788,-3.2214 0.5846,-1.3314 1.6662,-2.0254 1.0874,-0.6996 2.59,-0.6996 1.5025,0 2.5841,0.6996 1.0874,0.6996 1.6721,2.031 0.5846,1.3258 0.5788,3.2158 0,1.9013 -0.5846,3.2496 -0.5788,1.3484 -1.6604,2.0592 -1.0816,0.7109 -2.59,0.7109zM6.5424,15.9748q1.029,0 1.6428,-0.9986 0.6139,-0.9986 0.608,-2.9957 0,-1.3145 -0.2806,-2.189 -0.2748,-0.8745 -0.7834,-1.3145 -0.5028,-0.4401 -1.1868,-0.4401 -1.0231,0 -1.637,0.9873 -0.6139,0.9873 -0.6197,2.9563 0,1.3314 0.2748,2.2228 0.2806,0.8857 0.7893,1.3314 0.5086,0.4401 1.1927,0.4401z"
android:strokeWidth="0.404319"/>
android:strokeWidth="0.404319" />
<path
android:fillColor="#FF000000"
android:pathData="m17.5102,6.0002q0.9237,0 1.7773,0.299 0.8594,0.2934 1.5318,0.9534 0.6782,0.6601 1.0699,1.7489 0.3976,1.0832 0.4034,2.6685 -0.0058,1.4725 -0.3508,2.629 -0.3391,1.1509 -0.9763,1.9577 -0.6373,0.8068 -1.5376,1.2299 -0.8945,0.4175 -2.0053,0.4175 -1.1985,0 -2.1164,-0.4457 -0.9179,-0.4513 -1.4791,-1.2243 -0.5554,-0.7786 -0.6723,-1.7489h2.4964q0.1462,0.6319 0.6139,0.9817 0.4677,0.3441 1.1576,0.3441 1.1693,0 1.7773,-0.9817 0.608,-0.9873 0.6139,-2.7024h-0.0818q-0.2689,0.5078 -0.725,0.8745 -0.456,0.3611 -1.0465,0.5585 -0.5846,0.1975 -1.2453,0.1975 -1.0582,0 -1.8942,-0.4795 -0.8302,-0.4795 -1.3096,-1.3202 -0.4794,-0.8463 -0.4736,-1.9295 -0.0058,-1.1735 0.5554,-2.0818 0.5613,-0.914 1.5668,-1.433 1.0114,-0.519 2.3503,-0.5134zM17.5278,7.9184q-0.5905,0 -1.0524,0.2708 -0.456,0.2708 -0.725,0.7334 -0.2631,0.4626 -0.2572,1.0381 -0.0058,0.5755 0.2514,1.0324 0.2631,0.457 0.7191,0.7278 0.456,0.2652 1.0407,0.2652 0.4385,0 0.8068,-0.158 0.3742,-0.158 0.6489,-0.4344 0.2806,-0.2821 0.4385,-0.6488 0.1579,-0.3724 0.1637,-0.7955 -0.0058,-0.5585 -0.2689,-1.0211 -0.2631,-0.4626 -0.725,-0.7334 -0.4619,-0.2764 -1.0407,-0.2764z"
android:strokeWidth="0.404319"/>
android:strokeWidth="0.404319" />
</vector>

View file

@ -7,13 +7,13 @@
<path
android:pathData="m15.5,3.4563c-2.3333,0 -4.6667,0 -7,0 1.1667,-1.152 2.3333,-2.304 3.5,-3.456 1.1667,1.152 2.3333,2.304 3.5,3.456z"
android:strokeWidth="0.139935"
android:fillColor="#000000"/>
android:fillColor="#000000" />
<path
android:fillColor="#FF000000"
android:pathData="M6.5424,18.0001Q5.034,17.9945 3.9466,17.2836 2.865,16.5728 2.2804,15.2244 1.7016,13.876 1.7074,11.9804q0,-1.89 0.5788,-3.2214 0.5846,-1.3314 1.6662,-2.0254 1.0874,-0.6996 2.59,-0.6996 1.5025,0 2.5841,0.6996 1.0874,0.6996 1.6721,2.031 0.5846,1.3258 0.5788,3.2158 0,1.9013 -0.5846,3.2496 -0.5788,1.3484 -1.6604,2.0592 -1.0816,0.7109 -2.59,0.7109zM6.5424,15.9748q1.029,0 1.6428,-0.9986 0.6139,-0.9986 0.608,-2.9957 0,-1.3145 -0.2806,-2.189 -0.2748,-0.8745 -0.7834,-1.3145 -0.5028,-0.4401 -1.1868,-0.4401 -1.0231,0 -1.637,0.9873 -0.6139,0.9873 -0.6197,2.9563 0,1.3314 0.2748,2.2228 0.2806,0.8857 0.7893,1.3314 0.5086,0.4401 1.1927,0.4401z"
android:strokeWidth="0.404319"/>
android:strokeWidth="0.404319" />
<path
android:fillColor="#FF000000"
android:pathData="m17.5102,6.0002q0.9237,0 1.7773,0.299 0.8594,0.2934 1.5318,0.9534 0.6782,0.6601 1.0699,1.7489 0.3976,1.0832 0.4034,2.6685 -0.0058,1.4725 -0.3508,2.629 -0.3391,1.1509 -0.9763,1.9577 -0.6373,0.8068 -1.5376,1.2299 -0.8945,0.4175 -2.0053,0.4175 -1.1985,0 -2.1164,-0.4457 -0.9179,-0.4513 -1.4791,-1.2243 -0.5554,-0.7786 -0.6723,-1.7489h2.4964q0.1462,0.6319 0.6139,0.9817 0.4677,0.3441 1.1576,0.3441 1.1693,0 1.7773,-0.9817 0.608,-0.9873 0.6139,-2.7024h-0.0818q-0.2689,0.5078 -0.725,0.8745 -0.456,0.3611 -1.0465,0.5585 -0.5846,0.1975 -1.2453,0.1975 -1.0582,0 -1.8942,-0.4795 -0.8302,-0.4795 -1.3096,-1.3202 -0.4794,-0.8463 -0.4736,-1.9295 -0.0058,-1.1735 0.5554,-2.0818 0.5613,-0.914 1.5668,-1.433 1.0114,-0.519 2.3503,-0.5134zM17.5278,7.9184q-0.5905,0 -1.0524,0.2708 -0.456,0.2708 -0.725,0.7334 -0.2631,0.4626 -0.2572,1.0381 -0.0058,0.5755 0.2514,1.0324 0.2631,0.457 0.7191,0.7278 0.456,0.2652 1.0407,0.2652 0.4385,0 0.8068,-0.158 0.3742,-0.158 0.6489,-0.4344 0.2806,-0.2821 0.4385,-0.6488 0.1579,-0.3724 0.1637,-0.7955 -0.0058,-0.5585 -0.2689,-1.0211 -0.2631,-0.4626 -0.725,-0.7334 -0.4619,-0.2764 -1.0407,-0.2764z"
android:strokeWidth="0.404319"/>
android:strokeWidth="0.404319" />
</vector>

View file

@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="artist"
type="org.oxycblt.auxio.music.models.Artist" />