I got the exception from above which I know was discussed often here on SO. Anyways, the others don't tell me what's wrong with my code. These StyleAlbum
are just Music albums. getAdded()
returns the time when their last song was added to Android's MediaStore in milliseconds as int
.
This happens only on some devices!
Code:
public static List<StyleAlbum> sortAdded() {
List<StyleAlbum> mAlbums = new ArrayList<>();
mAlbums.addAll(Library.getAlbums());
Collections.sort(mAlbums, new Comparator<StyleAlbum>() {
@Override
public int compare(StyleAlbum lhs, StyleAlbum rhs) {
if (lhs.getAdded() > rhs.getAdded()) {
return -1;
} else return 1;
}
});
return mAlbums;
}