mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
fix: moved api call back to artist repository after losing the thread.
This commit is contained in:
parent
3eb9b2fb5c
commit
a187ba1e75
1 changed files with 32 additions and 10 deletions
|
|
@ -31,16 +31,38 @@ public class ArtistRepository {
|
||||||
public void getArtistAllSongs(String artistId, ArtistSongsCallback callback) {
|
public void getArtistAllSongs(String artistId, ArtistSongsCallback callback) {
|
||||||
Log.d("ArtistSync", "Getting albums for artist: " + artistId);
|
Log.d("ArtistSync", "Getting albums for artist: " + artistId);
|
||||||
|
|
||||||
// Use AlbumRepository to get all albums by this artist
|
// Get the artist info first, which contains the albums
|
||||||
albumRepository.getArtistAlbums(artistId).observeForever(albums -> {
|
App.getSubsonicClientInstance(false)
|
||||||
Log.d("ArtistSync", "Got albums: " + (albums != null ? albums.size() : 0));
|
.getBrowsingClient()
|
||||||
if (albums != null && !albums.isEmpty()) {
|
.getArtist(artistId)
|
||||||
fetchAllAlbumSongsWithCallback(albums, callback);
|
.enqueue(new Callback<ApiResponse>() {
|
||||||
} else {
|
@Override
|
||||||
Log.d("ArtistSync", "No albums found");
|
public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
||||||
callback.onSongsCollected(new ArrayList<>());
|
if (response.isSuccessful() && response.body() != null &&
|
||||||
}
|
response.body().getSubsonicResponse().getArtist() != null &&
|
||||||
});
|
response.body().getSubsonicResponse().getArtist().getAlbums() != null) {
|
||||||
|
|
||||||
|
List<AlbumID3> albums = response.body().getSubsonicResponse().getArtist().getAlbums();
|
||||||
|
Log.d("ArtistSync", "Got albums directly: " + albums.size());
|
||||||
|
|
||||||
|
if (!albums.isEmpty()) {
|
||||||
|
fetchAllAlbumSongsWithCallback(albums, callback);
|
||||||
|
} else {
|
||||||
|
Log.d("ArtistSync", "No albums found in artist response");
|
||||||
|
callback.onSongsCollected(new ArrayList<>());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.d("ArtistSync", "Failed to get artist info");
|
||||||
|
callback.onSongsCollected(new ArrayList<>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<ApiResponse> call, @NonNull Throwable t) {
|
||||||
|
Log.d("ArtistSync", "Error getting artist info: " + t.getMessage());
|
||||||
|
callback.onSongsCollected(new ArrayList<>());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchAllAlbumSongsWithCallback(List<AlbumID3> albums, ArtistSongsCallback callback) {
|
private void fetchAllAlbumSongsWithCallback(List<AlbumID3> albums, ArtistSongsCallback callback) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue