mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Implementation of the grid view of the playlist cover
This commit is contained in:
parent
b2b081947f
commit
dabef69662
2 changed files with 77 additions and 11 deletions
|
|
@ -14,12 +14,14 @@ import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.GranularRoundedCorners;
|
||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||||
import com.cappielloantonio.play.App;
|
import com.cappielloantonio.play.App;
|
||||||
import com.cappielloantonio.play.R;
|
import com.cappielloantonio.play.R;
|
||||||
import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
|
import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
|
||||||
import com.cappielloantonio.play.databinding.FragmentPlaylistPageBinding;
|
import com.cappielloantonio.play.databinding.FragmentPlaylistPageBinding;
|
||||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||||
|
import com.cappielloantonio.play.model.Song;
|
||||||
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;
|
||||||
|
|
@ -28,6 +30,7 @@ import com.cappielloantonio.play.util.MusicUtil;
|
||||||
import com.cappielloantonio.play.viewmodel.PlaylistPageViewModel;
|
import com.cappielloantonio.play.viewmodel.PlaylistPageViewModel;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class PlaylistPageFragment extends Fragment {
|
public class PlaylistPageFragment extends Fragment {
|
||||||
|
|
@ -151,11 +154,39 @@ public class PlaylistPageFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBackCover() {
|
private void initBackCover() {
|
||||||
CustomGlideRequest.Builder
|
playlistPageViewModel.getPlaylistSongLiveList(requireActivity()).observe(requireActivity(), songs -> {
|
||||||
.from(requireContext(), playlistPageViewModel.getPlaylist().getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
if (bind != null) {
|
||||||
.build()
|
Collections.shuffle(songs);
|
||||||
.transform(new RoundedCorners(CustomGlideRequest.CORNER_RADIUS))
|
|
||||||
.into(bind.playlistCoverImageView);
|
// Pic top-left
|
||||||
|
CustomGlideRequest.Builder
|
||||||
|
.from(requireContext(), songs.size() > 0 ? songs.get(0).getPrimary() : playlistPageViewModel.getPlaylist().getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||||
|
.build()
|
||||||
|
.transform(new GranularRoundedCorners(CustomGlideRequest.CORNER_RADIUS, 0, 0, 0))
|
||||||
|
.into(bind.playlistCoverImageViewTopLeft);
|
||||||
|
|
||||||
|
// Pic top-right
|
||||||
|
CustomGlideRequest.Builder
|
||||||
|
.from(requireContext(), songs.size() > 1 ? songs.get(1).getPrimary() : playlistPageViewModel.getPlaylist().getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||||
|
.build()
|
||||||
|
.transform(new GranularRoundedCorners(0, CustomGlideRequest.CORNER_RADIUS, 0, 0))
|
||||||
|
.into(bind.playlistCoverImageViewTopRight);
|
||||||
|
|
||||||
|
// Pic bottom-left
|
||||||
|
CustomGlideRequest.Builder
|
||||||
|
.from(requireContext(), songs.size() > 2 ? songs.get(2).getPrimary() : playlistPageViewModel.getPlaylist().getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||||
|
.build()
|
||||||
|
.transform(new GranularRoundedCorners(0, 0, 0, CustomGlideRequest.CORNER_RADIUS))
|
||||||
|
.into(bind.playlistCoverImageViewBottomLeft);
|
||||||
|
|
||||||
|
// Pic bottom-right
|
||||||
|
CustomGlideRequest.Builder
|
||||||
|
.from(requireContext(), songs.size() > 3 ? songs.get(3).getPrimary() : playlistPageViewModel.getPlaylist().getPrimary(), CustomGlideRequest.PLAYLIST_PIC, null)
|
||||||
|
.build()
|
||||||
|
.transform(new GranularRoundedCorners(0, 0, CustomGlideRequest.CORNER_RADIUS, 0))
|
||||||
|
.into(bind.playlistCoverImageViewBottomRight);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSongsView() {
|
private void initSongsView() {
|
||||||
|
|
@ -167,4 +198,8 @@ public class PlaylistPageFragment extends Fragment {
|
||||||
|
|
||||||
playlistPageViewModel.getPlaylistSongLiveList(requireActivity()).observe(requireActivity(), songs -> songHorizontalAdapter.setItems(songs));
|
playlistPageViewModel.getPlaylistSongLiveList(requireActivity()).observe(requireActivity(), songs -> songHorizontalAdapter.setItems(songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getPlaylistCornerCover(List<Song> songs, int corner) {
|
||||||
|
return songs.size() > corner ? songs.get(corner).getPrimary() : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -32,17 +32,48 @@
|
||||||
android:paddingTop="8dp">
|
android:paddingTop="8dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/playlist_cover_image_view"
|
android:id="@+id/playlist_cover_image_view_top_left"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginLeft="64dp"
|
android:layout_marginStart="64dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginRight="64dp"
|
app:layout_constraintDimensionRatio="H,1:1"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/playlist_cover_image_view_top_right"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/playlist_cover_image_view_top_right"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="64dp"
|
||||||
|
app:layout_constraintDimensionRatio="H,1:1"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/playlist_cover_image_view_top_left"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/playlist_cover_image_view_bottom_left"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginStart="64dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
app:layout_constraintDimensionRatio="H,1:1"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/playlist_cover_image_view_bottom_right"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/playlist_cover_image_view_top_left" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/playlist_cover_image_view_bottom_right"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginEnd="64dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
app:layout_constraintDimensionRatio="H,1:1"
|
app:layout_constraintDimensionRatio="H,1:1"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toEndOf="@id/playlist_cover_image_view_bottom_left"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="@id/playlist_cover_image_view_bottom_left" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/playlist_name_label"
|
android:id="@+id/playlist_name_label"
|
||||||
|
|
@ -59,7 +90,7 @@
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/playlist_cover_image_view" />
|
app:layout_constraintTop_toBottomOf="@+id/playlist_cover_image_view_bottom_left" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/playlist_song_count_label"
|
android:id="@+id/playlist_song_count_label"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue