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); 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 -> { bind.recentlyPlayedAlbumsTextViewClickable.setOnClickListener(v -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(Constants.ALBUM_RECENTLY_PLAYED, Constants.ALBUM_RECENTLY_PLAYED); 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()); pinnedPlaylists.setValue(Collections.emptyList());
playlistRepository.getPlaylists(false, -1).observe(owner, remotes -> { playlistRepository.getPlaylists(false, -1).observe(owner, remotes -> {
playlistRepository.getPinnedPlaylists().observe(owner, locals -> { if (remotes != null && !remotes.isEmpty()) {
if (remotes != null && locals != null) { List<Playlist> playlists = new ArrayList<>(remotes);
List<Playlist> toReturn = remotes.stream() Collections.shuffle(playlists);
.filter(remote -> locals.stream().anyMatch(local -> local.getId().equals(remote.getId()))) List<Playlist> randomPlaylists = playlists.size() > 5
.collect(Collectors.toList()); ? playlists.subList(0, 5)
: playlists;
pinnedPlaylists.setValue(toReturn); pinnedPlaylists.setValue(randomPlaylists);
} }
});
}); });
return pinnedPlaylists; return pinnedPlaylists;

View file

@ -379,16 +379,6 @@
android:paddingTop="8dp" android:paddingTop="8dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:paddingBottom="8dp" /> android:paddingBottom="8dp" />
</LinearLayout>
<!-- Best of -->
<LinearLayout
android:id="@+id/home_best_of_artist_sector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<TextView <TextView
android:id="@+id/most_streamed_song_pre_text_view" android:id="@+id/most_streamed_song_pre_text_view"
@ -400,6 +390,16 @@
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:text="@string/home_subtitle_best_of" android:text="@string/home_subtitle_best_of"
android:textAllCaps="true" /> android:textAllCaps="true" />
</LinearLayout>
<!-- Best of -->
<LinearLayout
android:id="@+id/home_best_of_artist_sector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<TextView <TextView
android:id="@+id/best_of_artist_text_view_refreshable" android:id="@+id/best_of_artist_text_view_refreshable"
@ -913,16 +913,36 @@
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"> tools:visibility="visible">
<!-- Label and button -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="8dp"
android:paddingTop="16dp"
android:paddingEnd="8dp"
android:paddingBottom="8dp">
<TextView <TextView
android:id="@+id/pinned_playlists_text_view" android:id="@+id/pinned_playlists_text_view"
style="@style/TitleLarge" style="@style/TitleLarge"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="16dp" android:layout_weight="1"
android:paddingTop="16dp" android:paddingStart="8dp"
android:paddingEnd="16dp" android:paddingEnd="8dp"
android:text="@string/home_title_pinned_playlists" /> android:text="@string/home_title_pinned_playlists" />
<TextView
android:id="@+id/playlist_catalogue_text_view_clickable"
style="@style/TitleMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:text="@string/library_title_playlist_see_all_button" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/pinned_playlists_recycler_view" android:id="@+id/pinned_playlists_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -65,6 +65,9 @@
<action <action
android:id="@+id/action_homeFragment_to_playlistPageFragment" android:id="@+id/action_homeFragment_to_playlistPageFragment"
app:destination="@id/playlistPageFragment" /> app:destination="@id/playlistPageFragment" />
<action
android:id="@+id/action_homeFragment_to_playlistCatalogueFragment"
app:destination="@id/playlistCatalogueFragment" />
<action <action
android:id="@+id/action_homeFragment_to_podcastChannelCatalogueFragment" android:id="@+id/action_homeFragment_to_podcastChannelCatalogueFragment"
app:destination="@id/podcastChannelCatalogueFragment" /> app:destination="@id/podcastChannelCatalogueFragment" />