mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Hide song/album/artist sector when there are no elements to show
This commit is contained in:
parent
b5eaa1e523
commit
02d6ad9629
3 changed files with 13 additions and 3 deletions
|
|
@ -88,7 +88,10 @@ public class LibraryFragment extends Fragment {
|
|||
|
||||
albumAdapter = new AlbumAdapter(requireContext());
|
||||
bind.albumRecyclerView.setAdapter(albumAdapter);
|
||||
libraryViewModel.getAlbumSample().observe(requireActivity(), albums -> albumAdapter.setItems(albums));
|
||||
libraryViewModel.getAlbumSample().observe(requireActivity(), albums -> {
|
||||
if(bind != null) bind.libraryAlbumSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
albumAdapter.setItems(albums);
|
||||
});
|
||||
}
|
||||
|
||||
private void initArtistView() {
|
||||
|
|
@ -97,7 +100,10 @@ public class LibraryFragment extends Fragment {
|
|||
|
||||
artistAdapter = new ArtistAdapter(requireContext());
|
||||
bind.artistRecyclerView.setAdapter(artistAdapter);
|
||||
libraryViewModel.getArtistSample().observe(requireActivity(), artists -> artistAdapter.setItems(artists));
|
||||
libraryViewModel.getArtistSample().observe(requireActivity(), artists -> {
|
||||
if(bind != null) bind.libraryArtistSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
artistAdapter.setItems(artists);
|
||||
});
|
||||
}
|
||||
|
||||
private void initGenreView() {
|
||||
|
|
@ -113,6 +119,7 @@ public class LibraryFragment extends Fragment {
|
|||
});
|
||||
bind.genreRecyclerView.setAdapter(genreAdapter);
|
||||
libraryViewModel.getGenreSample().observe(requireActivity(), genres -> {
|
||||
if(bind != null) bind.libraryGenresSector.setVisibility(!genres.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
genreAdapter.setItems(genres);
|
||||
});
|
||||
}
|
||||
|
|
@ -124,6 +131,7 @@ public class LibraryFragment extends Fragment {
|
|||
bind.playlistViewPager.setAdapter(playlistAdapter);
|
||||
bind.playlistViewPager.setOffscreenPageLimit(3);
|
||||
libraryViewModel.getPlaylistSample().observe(requireActivity(), playlists -> {
|
||||
if(bind != null) bind.libraryPlaylistSector.setVisibility(!playlists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
playlistAdapter.setItems(playlists);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class LibraryViewModel extends AndroidViewModel {
|
|||
|
||||
sampleAlbum = albumRepository.getAlbums("random", 20);
|
||||
sampleArtist = artistRepository.getArtists(true, 20);
|
||||
sampleGenres = new MutableLiveData<>();
|
||||
sampleGenres = new MutableLiveData<>(new ArrayList<>());
|
||||
playlistSample = playlistRepository.getPlaylists(true, 10);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
android:paddingBottom="@dimen/global_padding_bottom">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/library_album_sector"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
|
|
@ -64,6 +65,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/library_artist_sector"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue