mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-15 16:27:26 +00:00
fix: Avoid crash when server has no songs (#389)
This commit is contained in:
parent
253f8033c5
commit
e0ad4e3701
1 changed files with 12 additions and 3 deletions
|
|
@ -283,7 +283,10 @@ public class SongRepository {
|
||||||
@Override public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
@Override public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
||||||
List<Child> songs = new ArrayList<>();
|
List<Child> songs = new ArrayList<>();
|
||||||
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getRandomSongs() != null) {
|
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getRandomSongs() != null) {
|
||||||
songs.addAll(Objects.requireNonNull(response.body().getSubsonicResponse().getRandomSongs().getSongs()));
|
List<Child> returned = response.body().getSubsonicResponse().getRandomSongs().getSongs();
|
||||||
|
if (returned != null) {
|
||||||
|
songs.addAll(returned);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
randomSongsSample.setValue(songs);
|
randomSongsSample.setValue(songs);
|
||||||
}
|
}
|
||||||
|
|
@ -299,7 +302,10 @@ public class SongRepository {
|
||||||
@Override public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
@Override public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
||||||
List<Child> songs = new ArrayList<>();
|
List<Child> songs = new ArrayList<>();
|
||||||
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getRandomSongs() != null) {
|
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getRandomSongs() != null) {
|
||||||
songs.addAll(Objects.requireNonNull(response.body().getSubsonicResponse().getRandomSongs().getSongs()));
|
List<Child> returned = response.body().getSubsonicResponse().getRandomSongs().getSongs();
|
||||||
|
if (returned != null) {
|
||||||
|
songs.addAll(returned);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
randomSongsSample.setValue(songs);
|
randomSongsSample.setValue(songs);
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +348,10 @@ public class SongRepository {
|
||||||
@Override public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
@Override public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
||||||
List<Child> songs = new ArrayList<>();
|
List<Child> songs = new ArrayList<>();
|
||||||
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getSongsByGenre() != null) {
|
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getSongsByGenre() != null) {
|
||||||
songs.addAll(Objects.requireNonNull(response.body().getSubsonicResponse().getSongsByGenre().getSongs()));
|
List<Child> returned = response.body().getSubsonicResponse().getSongsByGenre().getSongs();
|
||||||
|
if (returned != null) {
|
||||||
|
songs.addAll(returned);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
songsByGenre.setValue(songs);
|
songsByGenre.setValue(songs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue