mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
feat: updated the horizontal song adapter with the disc name information
This commit is contained in:
parent
25900c848a
commit
b3b1c5b006
9 changed files with 66 additions and 15 deletions
|
|
@ -14,7 +14,9 @@ import com.cappielloantonio.tempo.R;
|
|||
import com.cappielloantonio.tempo.databinding.ItemHorizontalTrackBinding;
|
||||
import com.cappielloantonio.tempo.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.tempo.interfaces.ClickCallback;
|
||||
import com.cappielloantonio.tempo.subsonic.models.AlbumID3;
|
||||
import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||
import com.cappielloantonio.tempo.subsonic.models.DiscTitle;
|
||||
import com.cappielloantonio.tempo.util.Constants;
|
||||
import com.cappielloantonio.tempo.util.DownloadUtil;
|
||||
import com.cappielloantonio.tempo.util.MusicUtil;
|
||||
|
|
@ -23,20 +25,24 @@ import com.cappielloantonio.tempo.util.Preferences;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@UnstableApi
|
||||
public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAdapter.ViewHolder> {
|
||||
private final ClickCallback click;
|
||||
private final boolean showCoverArt;
|
||||
private final boolean showAlbum;
|
||||
private final AlbumID3 album;
|
||||
|
||||
private List<Child> songs;
|
||||
|
||||
public SongHorizontalAdapter(ClickCallback click, boolean showCoverArt, boolean showAlbum) {
|
||||
public SongHorizontalAdapter(ClickCallback click, boolean showCoverArt, boolean showAlbum, AlbumID3 album) {
|
||||
this.click = click;
|
||||
this.showCoverArt = showCoverArt;
|
||||
this.showAlbum = showAlbum;
|
||||
this.songs = Collections.emptyList();
|
||||
this.album = album;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
@ -81,8 +87,25 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
holder.item.trackNumberTextView.setVisibility(showCoverArt ? View.INVISIBLE : View.VISIBLE);
|
||||
holder.item.songCoverImageView.setVisibility(showCoverArt ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
if (!showCoverArt && (position > 0 && songs.get(position - 1) != null && songs.get(position - 1).getDiscNumber() != null && songs.get(position).getDiscNumber() != null && songs.get(position - 1).getDiscNumber() < songs.get(position).getDiscNumber())) {
|
||||
holder.item.differentDiskDivider.setVisibility(View.VISIBLE);
|
||||
if (!showCoverArt &&
|
||||
(position == 0 ||
|
||||
(position > 0 && songs.get(position - 1) != null &&
|
||||
songs.get(position - 1).getDiscNumber() != null &&
|
||||
songs.get(position).getDiscNumber() != null &&
|
||||
songs.get(position - 1).getDiscNumber() < songs.get(position).getDiscNumber()
|
||||
)
|
||||
)
|
||||
) {
|
||||
holder.item.differentDiskDividerSector.setVisibility(View.VISIBLE);
|
||||
holder.item.discTitleTextView.setText(holder.itemView.getContext().getString(R.string.disc_titleless, songs.get(position).getDiscNumber().toString()));
|
||||
|
||||
if (album.getDiscTitles() != null) {
|
||||
Optional<DiscTitle> discTitle = album.getDiscTitles().stream().filter(title -> Objects.equals(title.getDisc(), songs.get(position).getDiscNumber())).findFirst();
|
||||
|
||||
if (discTitle.isPresent() && discTitle.get().getTitle() != null) {
|
||||
holder.item.discTitleTextView.setText(holder.itemView.getContext().getString(R.string.disc_titleless, discTitle.get().getTitle()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Preferences.showItemRating()) {
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ public class AlbumPageFragment extends Fragment implements ClickCallback {
|
|||
bind.songRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.songRecyclerView.setHasFixedSize(true);
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, false, false);
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, false, false, albumPageViewModel.getAlbum());
|
||||
bind.songRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
|
||||
albumPageViewModel.getAlbumSongLiveList().observe(getViewLifecycleOwner(), songs -> songHorizontalAdapter.setItems(songs));
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ public class ArtistPageFragment extends Fragment implements ClickCallback {
|
|||
private void initTopSongsView() {
|
||||
bind.mostStreamedSongRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, true, true);
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, true, true, null);
|
||||
bind.mostStreamedSongRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
artistPageViewModel.getArtistTopSongList().observe(getViewLifecycleOwner(), songs -> {
|
||||
if (songs == null) {
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ public class HomeTabMusicFragment extends Fragment implements ClickCallback {
|
|||
|
||||
bind.starredTracksRecyclerView.setHasFixedSize(true);
|
||||
|
||||
starredSongAdapter = new SongHorizontalAdapter(this, true, false);
|
||||
starredSongAdapter = new SongHorizontalAdapter(this, true, false, null);
|
||||
bind.starredTracksRecyclerView.setAdapter(starredSongAdapter);
|
||||
homeViewModel.getStarredTracks(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), songs -> {
|
||||
if (songs == null) {
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public class PlaylistPageFragment extends Fragment implements ClickCallback {
|
|||
bind.songRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.songRecyclerView.setHasFixedSize(true);
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, true, false);
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, true, false, null);
|
||||
bind.songRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
|
||||
playlistPageViewModel.getPlaylistSongLiveList().observe(getViewLifecycleOwner(), songs -> songHorizontalAdapter.setItems(songs));
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public class SearchFragment extends Fragment implements ClickCallback {
|
|||
bind.searchResultTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.searchResultTracksRecyclerView.setHasFixedSize(true);
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, true, false);
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, true, false, null);
|
||||
bind.searchResultTracksRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public class SongListPageFragment extends Fragment implements ClickCallback {
|
|||
bind.songListRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.songListRecyclerView.setHasFixedSize(true);
|
||||
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, true, false);
|
||||
songHorizontalAdapter = new SongHorizontalAdapter(this, true, false, null);
|
||||
bind.songListRecyclerView.setAdapter(songHorizontalAdapter);
|
||||
songListPageViewModel.getSongList().observe(getViewLifecycleOwner(), songs -> {
|
||||
isLoading = false;
|
||||
|
|
|
|||
|
|
@ -9,14 +9,41 @@
|
|||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp">
|
||||
|
||||
<View
|
||||
android:id="@+id/different_disk_divider"
|
||||
style="@style/Divider"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/different_disk_divider_sector"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/disc_title_text_view"
|
||||
style="@style/LabelSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:singleLine="true"
|
||||
android:text="@string/label_placeholder"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/different_disk_divider"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/different_disk_divider"
|
||||
style="@style/Divider"
|
||||
android:layout_width="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/disc_title_text_view"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/disc_title_text_view"
|
||||
app:layout_constraintTop_toTopOf="@+id/disc_title_text_view"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/song_cover_image_view"
|
||||
|
|
@ -26,7 +53,7 @@
|
|||
android:layout_marginStart="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/different_disk_divider" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/different_disk_divider_sector" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/track_number_text_view"
|
||||
|
|
@ -38,7 +65,7 @@
|
|||
android:text="@string/label_placeholder"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/different_disk_divider" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/different_disk_divider_sector" />
|
||||
|
||||
<View
|
||||
android:id="@+id/cover_image_separator"
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
<string name="delete_download_storage_dialog_summary">Please be aware that continuing with this action will result in the permanent deletion of all saved items downloaded from all servers.</string>
|
||||
<string name="delete_download_storage_dialog_title">Delete saved items</string>
|
||||
<string name="description_empty_title">No description available</string>
|
||||
<string name="disc_titleless">Disc %1$s</string>
|
||||
<string name="download_directory_dialog_negative_button">Cancel</string>
|
||||
<string name="download_directory_dialog_positive_button">Download</string>
|
||||
<string name="download_directory_dialog_summary">All tracks in this folder will be downloaded. Tracks present in subfolders will not be downloaded.</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue