use of us.koller.cameraroll.data.models.Album in project Camera-Roll-Android-App by kollerlukas.
the class SortUtil method sortAlbums.
public static void sortAlbums(Activity context, ArrayList<Album> albums) {
Settings settings = Settings.getInstance(context);
int sortAlbumBy = settings.sortAlbumBy();
for (int i = 0; i < albums.size(); i++) {
sort(albums.get(i).getAlbumItems(), sortAlbumBy);
}
int sortAlbumsBy = settings.sortAlbumsBy();
switch(sortAlbumsBy) {
case BY_NAME:
case BY_DATE:
sort(albums, sortAlbumsBy);
return;
case BY_SIZE:
// Sorting
Collections.sort(albums, new Comparator<Album>() {
@Override
public int compare(Album a1, Album a2) {
if (a1 != null && a2 != null) {
if (a1.pinned() ^ a2.pinned()) {
return a2.pinned() ? 1 : -1;
}
Integer a1_size = a1.getAlbumItems().size();
Integer a2_size = a2.getAlbumItems().size();
return a2_size.compareTo(a1_size);
}
return 0;
}
});
break;
default:
break;
}
}
Aggregations