feat: added regular playlist to home view

This commit is contained in:
eddyizm 2025-12-22 11:04:25 -08:00
parent 9350a9cc2e
commit 526253723b
No known key found for this signature in database
GPG key ID: CF5F671829E8158A
4 changed files with 51 additions and 22 deletions

View file

@ -228,6 +228,12 @@ public class HomeTabMusicFragment extends Fragment implements ClickCallback {
activity.navController.navigate(R.id.action_homeFragment_to_albumListPageFragment, bundle);
});
bind.playlistCatalogueTextViewClickable.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putString(Constants.PLAYLIST_ALL, Constants.PLAYLIST_ALL);
activity.navController.navigate(R.id.action_homeFragment_to_playlistCatalogueFragment, bundle);
});
bind.recentlyPlayedAlbumsTextViewClickable.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putString(Constants.ALBUM_RECENTLY_PLAYED, Constants.ALBUM_RECENTLY_PLAYED);

View file

@ -248,15 +248,15 @@ public class HomeViewModel extends AndroidViewModel {
pinnedPlaylists.setValue(Collections.emptyList());
playlistRepository.getPlaylists(false, -1).observe(owner, remotes -> {
playlistRepository.getPinnedPlaylists().observe(owner, locals -> {
if (remotes != null && locals != null) {
List<Playlist> toReturn = remotes.stream()
.filter(remote -> locals.stream().anyMatch(local -> local.getId().equals(remote.getId())))
.collect(Collectors.toList());
if (remotes != null && !remotes.isEmpty()) {
List<Playlist> playlists = new ArrayList<>(remotes);
Collections.shuffle(playlists);
List<Playlist> randomPlaylists = playlists.size() > 5
? playlists.subList(0, 5)
: playlists;
pinnedPlaylists.setValue(toReturn);
}
});
pinnedPlaylists.setValue(randomPlaylists);
}
});
return pinnedPlaylists;