fix: handle empty albums and null mappings

This commit is contained in:
eddyizm 2025-12-07 10:04:05 -08:00
parent 37842fd897
commit e072a49288
No known key found for this signature in database
GPG key ID: CF5F671829E8158A
2 changed files with 108 additions and 74 deletions

View file

@ -205,6 +205,8 @@ public class AlbumRepository {
}
public void getInstantMix(AlbumID3 album, int count, MediaCallback callback) {
Log.d("AlbumRepository", "Attempting getInstantMix for AlbumID: " + album.getId());
App.getSubsonicClientInstance(false)
.getBrowsingClient()
.getSimilarSongs2(album.getId(), count)
@ -213,8 +215,17 @@ public class AlbumRepository {
public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
List<Child> songs = new ArrayList<>();
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getSimilarSongs2() != null) {
songs.addAll(response.body().getSubsonicResponse().getSimilarSongs2().getSongs());
if (response.isSuccessful()
&& response.body() != null
&& response.body().getSubsonicResponse().getSimilarSongs2() != null) {
List<Child> similarSongs = response.body().getSubsonicResponse().getSimilarSongs2().getSongs();
if (similarSongs == null) {
Log.w("AlbumRepository", "API successful but 'songs' list was NULL for AlbumID: " + album.getId());
} else {
songs.addAll(similarSongs);
}
}
callback.onLoadMedia(songs);
@ -298,4 +309,4 @@ public class AlbumRepository {
}
});
}
}
}