mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Set horizontal pagination in ArtistPageFragment top songs
This commit is contained in:
parent
f321a5520f
commit
c46c41db20
4 changed files with 25 additions and 12 deletions
7
.idea/misc.xml
generated
7
.idea/misc.xml
generated
|
|
@ -1,5 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="DesignSurface">
|
||||||
|
<option name="filePathToZoomLevelMap">
|
||||||
|
<map>
|
||||||
|
<entry key="app/src/main/res/layout/fragment_artist_page.xml" value="0.3229166666666667" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||||
|
|
||||||
import com.cappielloantonio.play.App;
|
import com.cappielloantonio.play.App;
|
||||||
import com.cappielloantonio.play.R;
|
import com.cappielloantonio.play.R;
|
||||||
|
|
@ -29,6 +31,7 @@ import com.cappielloantonio.play.repository.ArtistRepository;
|
||||||
import com.cappielloantonio.play.repository.QueueRepository;
|
import com.cappielloantonio.play.repository.QueueRepository;
|
||||||
import com.cappielloantonio.play.service.MusicPlayerRemote;
|
import com.cappielloantonio.play.service.MusicPlayerRemote;
|
||||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||||
|
import com.cappielloantonio.play.util.UIUtil;
|
||||||
import com.cappielloantonio.play.viewmodel.ArtistPageViewModel;
|
import com.cappielloantonio.play.viewmodel.ArtistPageViewModel;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -163,11 +166,18 @@ public class ArtistPageFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTopSongsView() {
|
private void initTopSongsView() {
|
||||||
bind.mostStreamedSongRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
bind.mostStreamedSongRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.mostStreamedSongRecyclerView.setAdapter(songHorizontalAdapter);
|
bind.mostStreamedSongRecyclerView.setAdapter(songHorizontalAdapter);
|
||||||
artistPageViewModel.getArtistTopSongList().observe(requireActivity(), songs -> songHorizontalAdapter.setItems(songs));
|
artistPageViewModel.getArtistTopSongList().observe(requireActivity(), songs -> {
|
||||||
|
if (bind != null) bind.artistPageTopSongsSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
|
bind.mostStreamedSongRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||||
|
songHorizontalAdapter.setItems(songs);
|
||||||
|
});
|
||||||
|
|
||||||
|
PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
|
||||||
|
pagerSnapHelper.attachToRecyclerView(bind.mostStreamedSongRecyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initAlbumsView() {
|
private void initAlbumsView() {
|
||||||
|
|
|
||||||
|
|
@ -173,8 +173,7 @@ public class HomeFragment extends Fragment {
|
||||||
recentlyPlayedAlbumAdapter = new AlbumAdapter(requireContext());
|
recentlyPlayedAlbumAdapter = new AlbumAdapter(requireContext());
|
||||||
bind.recentlyPlayedAlbumsRecyclerView.setAdapter(recentlyPlayedAlbumAdapter);
|
bind.recentlyPlayedAlbumsRecyclerView.setAdapter(recentlyPlayedAlbumAdapter);
|
||||||
homeViewModel.getRecentlyPlayedAlbumList().observe(requireActivity(), albums -> {
|
homeViewModel.getRecentlyPlayedAlbumList().observe(requireActivity(), albums -> {
|
||||||
if (bind != null)
|
if (bind != null) bind.homeRecentlyPlayedAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
bind.homeRecentlyPlayedAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
|
||||||
recentlyPlayedAlbumAdapter.setItems(albums);
|
recentlyPlayedAlbumAdapter.setItems(albums);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -202,8 +201,7 @@ public class HomeFragment extends Fragment {
|
||||||
starredSongAdapter = new SongHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
starredSongAdapter = new SongHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.starredTracksRecyclerView.setAdapter(starredSongAdapter);
|
bind.starredTracksRecyclerView.setAdapter(starredSongAdapter);
|
||||||
homeViewModel.getStarredTracks().observe(requireActivity(), songs -> {
|
homeViewModel.getStarredTracks().observe(requireActivity(), songs -> {
|
||||||
if (bind != null)
|
if (bind != null) bind.homeStarredTracksSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
bind.homeStarredTracksSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
|
||||||
bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
bind.starredTracksRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(songs.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||||
starredSongAdapter.setItems(songs);
|
starredSongAdapter.setItems(songs);
|
||||||
});
|
});
|
||||||
|
|
@ -218,8 +216,7 @@ public class HomeFragment extends Fragment {
|
||||||
starredAlbumAdapter = new AlbumHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
starredAlbumAdapter = new AlbumHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.starredAlbumsRecyclerView.setAdapter(starredAlbumAdapter);
|
bind.starredAlbumsRecyclerView.setAdapter(starredAlbumAdapter);
|
||||||
homeViewModel.getStarredAlbums().observe(requireActivity(), albums -> {
|
homeViewModel.getStarredAlbums().observe(requireActivity(), albums -> {
|
||||||
if (bind != null)
|
if (bind != null) bind.homeStarredAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
bind.homeStarredAlbumsSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
|
||||||
bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
bind.starredAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||||
starredAlbumAdapter.setItems(albums);
|
starredAlbumAdapter.setItems(albums);
|
||||||
});
|
});
|
||||||
|
|
@ -234,8 +231,7 @@ public class HomeFragment extends Fragment {
|
||||||
starredArtistAdapter = new ArtistHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
starredArtistAdapter = new ArtistHorizontalAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.starredArtistsRecyclerView.setAdapter(starredArtistAdapter);
|
bind.starredArtistsRecyclerView.setAdapter(starredArtistAdapter);
|
||||||
homeViewModel.getStarredArtists().observe(requireActivity(), artists -> {
|
homeViewModel.getStarredArtists().observe(requireActivity(), artists -> {
|
||||||
if (bind != null)
|
if (bind != null) bind.homeStarredArtistsSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
bind.homeStarredArtistsSector.setVisibility(!artists.isEmpty() ? View.VISIBLE : View.GONE);
|
|
||||||
bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
bind.starredArtistsRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(artists.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||||
starredArtistAdapter.setItems(artists);
|
starredArtistAdapter.setItems(artists);
|
||||||
});
|
});
|
||||||
|
|
@ -262,8 +258,7 @@ public class HomeFragment extends Fragment {
|
||||||
dowanloadedMusicAdapter = new RecentMusicAdapter(activity, requireContext(), getChildFragmentManager());
|
dowanloadedMusicAdapter = new RecentMusicAdapter(activity, requireContext(), getChildFragmentManager());
|
||||||
bind.downloadedTracksRecyclerView.setAdapter(dowanloadedMusicAdapter);
|
bind.downloadedTracksRecyclerView.setAdapter(dowanloadedMusicAdapter);
|
||||||
homeViewModel.getDownloaded().observe(requireActivity(), downloads -> {
|
homeViewModel.getDownloaded().observe(requireActivity(), downloads -> {
|
||||||
if (bind != null)
|
if (bind != null) bind.homeDownloadedTracksSector.setVisibility(!downloads.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
bind.homeDownloadedTracksSector.setVisibility(!downloads.isEmpty() ? View.VISIBLE : View.GONE);
|
|
||||||
dowanloadedMusicAdapter.setItems(MappingUtil.mapDownload(downloads));
|
dowanloadedMusicAdapter.setItems(MappingUtil.mapDownload(downloads));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,7 @@
|
||||||
|
|
||||||
<!-- Label and button -->
|
<!-- Label and button -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/artist_page_top_songs_sector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue