Hi guys,
I just found a solution for multi-Discs Albums display into iSub (which actually doesn't use DiscNumber parameter).
The problem is in the file RESTBrowseController.java, in the definition of trackComparator variable.
The current definition :
- Code: Select all
private final Comparator<Track> trackComparator = new Comparator<Track>() {
@Override
public int compare(Track t1, Track t2) {
return Integer.compare(getTrackNr(t1.getMetaData().getTrackNr()),
getTrackNr(t2.getMetaData().getTrackNr()));
}
private int getTrackNr(Short nr) {
return nr == null ? 0 : nr.intValue();
}
};
with this method, the rest response is sorted only on trackNumber parameter, so when you call a multi-disc album, it returns tracks sorted like this : 1, 1, 2, 2, 3, 3...
To correct this issue, we need to use discNumber parameter and trackNumber parameters together.
So, the idea is to concatenate discNumber and trackNumber (formatted with 2 digits).
For exemple for the first track of the first disc, we will have 0101 and for the first track of the second disc, we'l have 0201 which is greater than 0101, the rest response is now correctly sorted by changing the variable definition like this :
- Code: Select all
private final Comparator<Track> trackComparator = new Comparator<Track>() {
@Override
public int compare(Track t1, Track t2) {
//germain
Short x1 = Short.valueOf(String.format("%02d", t1.getMetaData().getDiscNr()).concat(String.format("%02d", t1.getMetaData().getTrackNr())));
Short x2 = Short.valueOf(String.format("%02d", t2.getMetaData().getDiscNr()).concat(String.format("%02d", t2.getMetaData().getTrackNr())));
return Integer.compare(x1,x2);
//germain
}
private int getTrackNr(Short nr) {
return nr == null ? 0 : nr.intValue();
}
};