mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 18:31:40 +00:00
Hide sector in home and library if there are no elements to show
This commit is contained in:
parent
bdfa4a6f64
commit
93e7550e74
4 changed files with 22 additions and 4 deletions
|
|
@ -138,7 +138,10 @@ public class HomeFragment extends Fragment {
|
||||||
|
|
||||||
favoriteSongAdapter = new SongResultSearchAdapter(activity, requireContext(), getChildFragmentManager());
|
favoriteSongAdapter = new SongResultSearchAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.favoritesTracksRecyclerView.setAdapter(favoriteSongAdapter);
|
bind.favoritesTracksRecyclerView.setAdapter(favoriteSongAdapter);
|
||||||
homeViewModel.getFavorites().observe(requireActivity(), songs -> favoriteSongAdapter.setItems(songs));
|
homeViewModel.getFavorites().observe(requireActivity(), songs -> {
|
||||||
|
bind.homeFavoriteTracksSector.setVisibility(songs.size() > 0 ? View.VISIBLE : View.GONE);
|
||||||
|
favoriteSongAdapter.setItems(songs);
|
||||||
|
});
|
||||||
|
|
||||||
PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
|
PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
|
||||||
pagerSnapHelper.attachToRecyclerView(bind.favoritesTracksRecyclerView);
|
pagerSnapHelper.attachToRecyclerView(bind.favoritesTracksRecyclerView);
|
||||||
|
|
@ -150,7 +153,10 @@ public class HomeFragment extends Fragment {
|
||||||
|
|
||||||
mostPlayedMusicAdapter = new RecentMusicAdapter(activity, requireContext(), getChildFragmentManager());
|
mostPlayedMusicAdapter = new RecentMusicAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.mostPlayedTracksRecyclerView.setAdapter(mostPlayedMusicAdapter);
|
bind.mostPlayedTracksRecyclerView.setAdapter(mostPlayedMusicAdapter);
|
||||||
homeViewModel.getMostPlayedSongList().observe(requireActivity(), songs -> mostPlayedMusicAdapter.setItems(songs));
|
homeViewModel.getMostPlayedSongList().observe(requireActivity(), songs -> {
|
||||||
|
bind.homeMostPlayedTracksSector.setVisibility(songs.size() > 0 ? View.VISIBLE : View.GONE);
|
||||||
|
mostPlayedMusicAdapter.setItems(songs);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initRecentPlayedSongView() {
|
private void initRecentPlayedSongView() {
|
||||||
|
|
@ -159,7 +165,10 @@ public class HomeFragment extends Fragment {
|
||||||
|
|
||||||
recentlyPlayedMusicAdapter = new RecentMusicAdapter(activity, requireContext(), getChildFragmentManager());
|
recentlyPlayedMusicAdapter = new RecentMusicAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.recentlyPlayedTracksRecyclerView.setAdapter(recentlyPlayedMusicAdapter);
|
bind.recentlyPlayedTracksRecyclerView.setAdapter(recentlyPlayedMusicAdapter);
|
||||||
homeViewModel.getRecentlyPlayedSongList().observe(requireActivity(), songs -> recentlyPlayedMusicAdapter.setItems(songs));
|
homeViewModel.getRecentlyPlayedSongList().observe(requireActivity(), songs -> {
|
||||||
|
bind.homeRecentlyPlayedTracksSector.setVisibility(songs.size() > 0 ? View.VISIBLE : View.GONE);
|
||||||
|
recentlyPlayedMusicAdapter.setItems(songs);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDiscoverSongSlideViewOffset(float pageOffset, float pageMargin) {
|
private void setDiscoverSongSlideViewOffset(float pageOffset, float pageMargin) {
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,10 @@ public class LibraryFragment extends Fragment {
|
||||||
|
|
||||||
playlistAdapter = new PlaylistAdapter(requireContext());
|
playlistAdapter = new PlaylistAdapter(requireContext());
|
||||||
bind.playlistRecyclerView.setAdapter(playlistAdapter);
|
bind.playlistRecyclerView.setAdapter(playlistAdapter);
|
||||||
libraryViewModel.getPlaylistList().observe(requireActivity(), playlists -> playlistAdapter.setItems(playlists));
|
libraryViewModel.getPlaylistList().observe(requireActivity(), playlists -> {
|
||||||
|
bind.libraryPlaylistSector.setVisibility(playlists.size() > 0 ? View.VISIBLE : View.GONE);
|
||||||
|
playlistAdapter.setItems(playlists);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCatalogueSyncCheck() {
|
private void initCatalogueSyncCheck() {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
<!-- Recently added tracks -->
|
<!-- Recently added tracks -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/home_recently_added_tracks_sector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
@ -98,6 +99,7 @@
|
||||||
|
|
||||||
<!-- Fashback -->
|
<!-- Fashback -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/home_flashback_sector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
@ -130,6 +132,7 @@
|
||||||
|
|
||||||
<!-- Favorites -->
|
<!-- Favorites -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/home_favorite_tracks_sector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
@ -184,6 +187,7 @@
|
||||||
|
|
||||||
<!-- Most played tracks -->
|
<!-- Most played tracks -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/home_most_played_tracks_sector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
@ -240,6 +244,7 @@
|
||||||
|
|
||||||
<!-- Recently played tracks -->
|
<!-- Recently played tracks -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/home_recently_played_tracks_sector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/library_playlist_sector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue