Merge branch 'eddyizm:development' into development

This commit is contained in:
skajmer 2025-11-01 09:52:55 +01:00 committed by GitHub
commit 4464b5b34d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 50 additions and 9 deletions

View file

@ -13,9 +13,11 @@ import com.cappielloantonio.tempo.subsonic.models.Child;
import com.cappielloantonio.tempo.subsonic.models.IndexID3;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import retrofit2.Call;
import retrofit2.Callback;
@ -312,24 +314,42 @@ public class ArtistRepository {
App.getSubsonicClientInstance(false)
.getBrowsingClient()
.getTopSongs(artist.getName(), count)
.getArtist(artist.getId())
.enqueue(new Callback<ApiResponse>() {
@Override
public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getTopSongs() != null && response.body().getSubsonicResponse().getTopSongs().getSongs() != null) {
List<Child> songs = response.body().getSubsonicResponse().getTopSongs().getSongs();
if (response.isSuccessful() && response.body() != null &&
response.body().getSubsonicResponse().getArtist() != null &&
response.body().getSubsonicResponse().getArtist().getAlbums() != null) {
if (songs != null && !songs.isEmpty()) {
Collections.shuffle(songs);
List<AlbumID3> albums = response.body().getSubsonicResponse().getArtist().getAlbums();
Log.d("ArtistRepository", "Got albums directly: " + albums.size());
if (albums.isEmpty()) {
Log.d("ArtistRepository", "No albums found in artist response");
return;
}
randomSongs.setValue(songs);
Collections.shuffle(albums);
int[] counts = albums.stream().mapToInt(AlbumID3::getSongCount).toArray();
Arrays.parallelPrefix(counts, Integer::sum);
int albumLimit = 0;
int multiplier = 4; // get more than the limit so we can shuffle them
while (albumLimit < albums.size() && counts[albumLimit] < count * multiplier)
albumLimit++;
Log.d("ArtistRepository", String.format("Retaining %d/%d albums", albumLimit, albums.size()));
fetchAllAlbumSongsWithCallback(albums.stream().limit(albumLimit).collect(Collectors.toList()), songs -> {
Collections.shuffle(songs);
randomSongs.setValue(songs.stream().limit(count).collect(Collectors.toList()));
});
} else {
Log.d("ArtistRepository", "Failed to get artist info");
}
}
@Override
public void onFailure(@NonNull Call<ApiResponse> call, @NonNull Throwable t) {
Log.d("ArtistRepository", "Error getting artist info: " + t.getMessage());
}
});

View file

@ -188,8 +188,6 @@ public class ArtistPageFragment extends Fragment implements ClickCallback {
} else {
if (bind != null)
bind.artistPageTopSongsSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
if (bind != null)
bind.artistPageShuffleButton.setEnabled(!songs.isEmpty());
songHorizontalAdapter.setItems(songs);
reapplyPlayback();
}

View file

@ -89,6 +89,9 @@ public class ArtistBottomSheetDialog extends BottomSheetDialogFragment implement
ArtistRepository artistRepository = new ArtistRepository();
artistRepository.getInstantMix(artist, 20).observe(getViewLifecycleOwner(), songs -> {
// navidrome may return null for this
if (songs == null)
return;
MusicUtil.ratingFilter(songs);
if (!songs.isEmpty()) {

View file

@ -413,7 +413,9 @@
<string name="share_bottom_sheet_delete">Eliminar compartición</string>
<string name="share_bottom_sheet_update">Actualizar compartición</string>
<string name="share_subtitle_item">Fecha de caducidad: %1$s</string>
<string name="share_no_expiration">Nunca</string>
<string name="share_unsupported_error">El uso compartido no está soportado o no está habilitado</string>
<string name="asset_link_debug_toast">Enlace de recurso: %1$s</string>
<string name="share_update_dialog_hint_description">Descripción</string>
<string name="share_update_dialog_hint_expiration_date">Fecha de caducidad</string>
<string name="song_bottom_sheet_add_to_queue">Añadir a la cola</string>
@ -486,4 +488,21 @@
<string name="settings_sync_starred_artists_for_offline_use_summary">Si está habilitada, los artistas destacados se descargarán para uso sin conexión.</string>
<string name="widget_time_elapsed_placeholder">0:00</string>
<string name="exo_controls_heart_off_description">Eliminar de favoritos</string>
<string name="asset_link_chip_text">%1$s • %2$s</string>
<string name="asset_link_copied_toast">Copiado %1$s al portapapeles</string>
<string name="settings_album_detail">Mostrar los detalles del álbum</string>
<string name="settings_album_detail_summary">Si está habilitada, muestra los detalles del álbum, como el género, el número de pistas, etc. en la página de álbum</string>
<string name="asset_link_clipboard_label">Enlace de recurso de Tempus</string>
<string name="asset_link_label_song">UID de la pista</string>
<string name="asset_link_label_album">UID del álbum</string>
<string name="asset_link_label_artist">UID del artista</string>
<string name="asset_link_label_playlist">UID de la lista de reproducción</string>
<string name="asset_link_label_genre">UID del género</string>
<string name="asset_link_label_year">UID del año</string>
<string name="asset_link_label_unknown">UID del recurso</string>
<string name="asset_link_error_unsupported">Enlace de recurso no válido</string>
<string name="asset_link_error_song">No se ha podido abrir la pista</string>
<string name="asset_link_error_album">No se ha podido abrir el álbum</string>
<string name="asset_link_error_artist">No se ha podido abrir el artista</string>
<string name="asset_link_error_playlist">No se ha podido abrir la lista de reproducción</string>
</resources>