From 2624f396e5c94f4cb0e5f2cd42518be05402cfd3 Mon Sep 17 00:00:00 2001 From: eddyizm Date: Fri, 26 Dec 2025 22:08:07 -0800 Subject: [PATCH] wip: refactor album repo to use the song repo instant mix --- .../tempo/repository/AlbumRepository.java | 40 +++++-------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/com/cappielloantonio/tempo/repository/AlbumRepository.java b/app/src/main/java/com/cappielloantonio/tempo/repository/AlbumRepository.java index c3533549..7de91d18 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/repository/AlbumRepository.java +++ b/app/src/main/java/com/cappielloantonio/tempo/repository/AlbumRepository.java @@ -2,6 +2,7 @@ package com.cappielloantonio.tempo.repository; import androidx.annotation.NonNull; import androidx.lifecycle.MutableLiveData; + import android.util.Log; import com.cappielloantonio.tempo.App; @@ -204,38 +205,15 @@ public class AlbumRepository { return albumInfo; } - 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) - .enqueue(new Callback() { - @Override - public void onResponse(@NonNull Call call, @NonNull Response response) { - List songs = new ArrayList<>(); + public void getInstantMix(AlbumID3 album, int count, final MediaCallback callback) { + Log.d("AlbumRepository", "Starting Instant Mix for album: " + album.getName()); - if (response.isSuccessful() - && response.body() != null - && response.body().getSubsonicResponse().getSimilarSongs2() != null) { - - List 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); - } - } + new SongRepository().getInstantMix(album.getId(), count, songs -> { - callback.onLoadMedia(songs); - } - - @Override - public void onFailure(@NonNull Call call, @NonNull Throwable t) { - callback.onLoadMedia(new ArrayList<>()); - } - }); + if (songs != null && !songs.isEmpty()) { + callback.onLoadMedia(songs); + } + }); } public MutableLiveData> getDecades() { @@ -248,7 +226,7 @@ public class AlbumRepository { @Override public void onLoadYear(int last) { if (first != -1 && last != -1) { - List decadeList = new ArrayList(); + List decadeList = new ArrayList<>(); int startDecade = first - (first % 10); int lastDecade = last - (last % 10);