mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-16 00:37:25 +00:00
fix: handle empty albums and null mappings
This commit is contained in:
parent
37842fd897
commit
e072a49288
2 changed files with 108 additions and 74 deletions
|
|
@ -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 {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue