mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
Set track number inside the track adapter in AlbumPageFragment
This commit is contained in:
parent
9ae9873326
commit
d78668d6c5
11 changed files with 50 additions and 14 deletions
|
|
@ -34,14 +34,16 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
private final MainActivity mainActivity;
|
||||
private final Context context;
|
||||
private final LayoutInflater mInflater;
|
||||
private final boolean isCoverVisible;
|
||||
|
||||
private List<Song> songs;
|
||||
|
||||
public SongHorizontalAdapter(MainActivity mainActivity, Context context) {
|
||||
public SongHorizontalAdapter(MainActivity mainActivity, Context context, boolean isCoverVisible) {
|
||||
this.mainActivity = mainActivity;
|
||||
this.context = context;
|
||||
this.mInflater = LayoutInflater.from(context);
|
||||
this.songs = new ArrayList<>();
|
||||
this.isCoverVisible = isCoverVisible;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
@ -58,6 +60,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
holder.songTitle.setText(MusicUtil.getReadableString(song.getTitle()));
|
||||
holder.songArtist.setText(MusicUtil.getReadableString(song.getArtistName()));
|
||||
holder.songDuration.setText(MusicUtil.getReadableDurationString(song.getDuration(), false));
|
||||
holder.trackNumber.setText(String.valueOf(song.getTrackNumber()));
|
||||
|
||||
if (DownloadUtil.getDownloadTracker(context).isDownloaded(song)) {
|
||||
holder.downloadIndicator.setVisibility(View.VISIBLE);
|
||||
|
|
@ -65,11 +68,15 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
holder.downloadIndicator.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
if(isCoverVisible) CustomGlideRequest.Builder
|
||||
.from(context, song.getPrimary(), CustomGlideRequest.SONG_PIC, null)
|
||||
.build()
|
||||
.transform(new RoundedCorners(CustomGlideRequest.CORNER_RADIUS))
|
||||
.into(holder.cover);
|
||||
|
||||
if(isCoverVisible) holder.trackNumber.setVisibility(View.INVISIBLE);
|
||||
|
||||
if(!isCoverVisible) holder.cover.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -90,7 +97,9 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
TextView songTitle;
|
||||
TextView songArtist;
|
||||
TextView songDuration;
|
||||
TextView trackNumber;
|
||||
View downloadIndicator;
|
||||
View coverSeparator;
|
||||
ImageView more;
|
||||
ImageView cover;
|
||||
|
||||
|
|
@ -100,9 +109,11 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
songTitle = itemView.findViewById(R.id.search_result_song_title_text_view);
|
||||
songArtist = itemView.findViewById(R.id.album_artist_text_view);
|
||||
songDuration = itemView.findViewById(R.id.search_result_song_duration_text_view);
|
||||
trackNumber = itemView.findViewById(R.id.track_number_text_view);
|
||||
downloadIndicator = itemView.findViewById(R.id.search_result_dowanload_indicator_image_view);
|
||||
more = itemView.findViewById(R.id.search_result_song_more_button);
|
||||
cover = itemView.findViewById(R.id.song_cover_image_view);
|
||||
coverSeparator = itemView.findViewById(R.id.cover_image_separator);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ public class AlbumPageFragment extends Fragment {
|
|||
bind.songRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.songRecyclerView.setHasFixedSize(true);
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext());
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext(), false);
|
||||
bind.songRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
|
||||
albumPageViewModel.getAlbumSongLiveList().observe(requireActivity(), songs -> {
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ public class ArtistPageFragment extends Fragment {
|
|||
private void initTopSongsView() {
|
||||
bind.mostStreamedSongRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext());
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext(), true);
|
||||
bind.mostStreamedSongRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
artistPageViewModel.getArtistTopSongList(10).observe(requireActivity(), songs -> {
|
||||
if (bind != null) bind.artistPageTopSongsSector.setVisibility(!songs.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ public class DownloadFragment extends Fragment {
|
|||
private void initDownloadedSongView() {
|
||||
bind.downloadedTracksRecyclerView.setHasFixedSize(true);
|
||||
|
||||
downloadedTrackAdapter = new SongHorizontalAdapter(activity, requireContext());
|
||||
downloadedTrackAdapter = new SongHorizontalAdapter(activity, requireContext(), true);
|
||||
bind.downloadedTracksRecyclerView.setAdapter(downloadedTrackAdapter);
|
||||
downloadViewModel.getDownloadedTracks(requireActivity(), 20).observe(requireActivity(), songs -> {
|
||||
if (songs == null) {
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ public class HomeFragment extends Fragment {
|
|||
private void initStarredTracksView() {
|
||||
bind.starredTracksRecyclerView.setHasFixedSize(true);
|
||||
|
||||
starredSongAdapter = new SongHorizontalAdapter(activity, requireContext());
|
||||
starredSongAdapter = new SongHorizontalAdapter(activity, requireContext(), true);
|
||||
bind.starredTracksRecyclerView.setAdapter(starredSongAdapter);
|
||||
homeViewModel.getStarredTracks(requireActivity()).observe(requireActivity(), songs -> {
|
||||
if (songs == null) {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class PlaylistPageFragment extends Fragment {
|
|||
bind.songRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.songRecyclerView.setHasFixedSize(true);
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext());
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext(), true);
|
||||
bind.songRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
|
||||
playlistPageViewModel.getPlaylistSongLiveList().observe(requireActivity(), songs -> {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class SearchFragment extends Fragment {
|
|||
bind.searchResultTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.searchResultTracksRecyclerView.setHasFixedSize(true);
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext());
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext(), true);
|
||||
bind.searchResultTracksRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
|
||||
// Albums
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ public class SongListPageFragment extends Fragment {
|
|||
bind.songListRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.songListRecyclerView.setHasFixedSize(true);
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext());
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(activity, requireContext(), true);
|
||||
bind.songListRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
songListPageViewModel.getSongList(requireActivity()).observe(requireActivity(), songs -> songHorizontalAdapter.setItems(songs));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue