fix: sort genres alphabetically as server's default sorting could lead to unpredictable results

This commit is contained in:
antonio 2024-01-28 23:40:03 +01:00
parent 634de67d74
commit 279302737d

View file

@ -8,7 +8,9 @@ import com.cappielloantonio.tempo.subsonic.base.ApiResponse;
import com.cappielloantonio.tempo.subsonic.models.Genre; import com.cappielloantonio.tempo.subsonic.models.Genre;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -39,7 +41,7 @@ public class GenreRepository {
if (size != -1) { if (size != -1) {
genres.setValue(genreList.subList(0, Math.min(size, genreList.size()))); genres.setValue(genreList.subList(0, Math.min(size, genreList.size())));
} else { } else {
genres.setValue(genreList); genres.setValue(genreList.stream().sorted(Comparator.comparing(Genre::getGenre)).collect(Collectors.toList()));
} }
} }
} }