Fall back to path when comparing tracks

Tracks will be sorted by ascending path if neither album, disc and track
id can help.

This is helpful for browsing a loose collection of tracks tagged under
the same album.

Signed-off-by: lbonn <bonnans.l@gmail.com>
This commit is contained in:
lbonn 2020-12-18 01:20:58 +01:00
parent 0ce5a56051
commit 7af666037d
No known key found for this signature in database
GPG Key ID: BF9070C03E67A72D
1 changed files with 10 additions and 1 deletions

View File

@ -18,6 +18,8 @@ public class EntryByDiscAndTrackComparator implements Comparator<MusicDirectory.
Integer trackY = y.getTrack();
String albumX = x.getAlbum();
String albumY = y.getAlbum();
String pathX = x.getPath();
String pathY = y.getPath();
int albumComparison = compare(albumX, albumY);
@ -33,7 +35,14 @@ public class EntryByDiscAndTrackComparator implements Comparator<MusicDirectory.
return discComparison;
}
return compare(trackX == null ? 0 : trackX, trackY == null ? 0 : trackY);
int trackComparison = compare(trackX == null ? 0 : trackX, trackY == null ? 0 : trackY);
if (trackComparison != 0)
{
return trackComparison;
}
return compare(pathX == null ? "" : pathX, pathY == null ? "" : pathY);
}
private static int compare(long a, long b)