change songs compareTo to take the disc number into account

This commit is contained in:
Adrian Ulrich committed 2017-11-29 21:37:45 +01:00
1 parent 38fb581ee1
commit 2df538ccc5
1 file changed
+12 -7
+12 -7
View File
@@ -251,15 +251,20 @@ public class Song implements Comparable<Song> {
}
/**
* Compares the album ids of the two songs; if equal, compares track order.
* Compares the virtual order of two song objects.
*/
@Override
public int compareTo(Song other)
{
if (albumId == other.albumId)
public int compareTo(Song other) {
if (albumId != other.albumId)
return (albumId > other.albumId ? 1 : -1); // albumId is long, avoid overflow fun.
if (discNumber != other.discNumber)
return discNumber - other.discNumber;
if (trackNumber != other.trackNumber)
return trackNumber - other.trackNumber;
if (albumId > other.albumId)
return 1;
return -1;
// else: is equal
return 0;
}
}