mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Added shuffle and radio button in artist's page
This commit is contained in:
parent
7b950f4e5c
commit
3fcc9242b3
3 changed files with 101 additions and 26 deletions
|
|
@ -3,6 +3,7 @@ package com.cappielloantonio.play.ui.fragment;
|
||||||
import android.graphics.BlendMode;
|
import android.graphics.BlendMode;
|
||||||
import android.graphics.BlendModeColorFilter;
|
import android.graphics.BlendModeColorFilter;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
@ -20,12 +21,16 @@ import com.cappielloantonio.play.adapter.AlbumArtistPageAdapter;
|
||||||
import com.cappielloantonio.play.adapter.SongResultSearchAdapter;
|
import com.cappielloantonio.play.adapter.SongResultSearchAdapter;
|
||||||
import com.cappielloantonio.play.databinding.FragmentArtistPageBinding;
|
import com.cappielloantonio.play.databinding.FragmentArtistPageBinding;
|
||||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||||
|
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||||
import com.cappielloantonio.play.service.MusicPlayerRemote;
|
import com.cappielloantonio.play.service.MusicPlayerRemote;
|
||||||
import com.cappielloantonio.play.model.Song;
|
import com.cappielloantonio.play.model.Song;
|
||||||
import com.cappielloantonio.play.repository.QueueRepository;
|
import com.cappielloantonio.play.repository.QueueRepository;
|
||||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||||
|
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||||
|
import com.cappielloantonio.play.util.SyncUtil;
|
||||||
import com.cappielloantonio.play.viewmodel.ArtistPageViewModel;
|
import com.cappielloantonio.play.viewmodel.ArtistPageViewModel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ArtistPageFragment extends Fragment {
|
public class ArtistPageFragment extends Fragment {
|
||||||
|
|
@ -54,6 +59,7 @@ public class ArtistPageFragment extends Fragment {
|
||||||
|
|
||||||
init();
|
init();
|
||||||
initBackdrop();
|
initBackdrop();
|
||||||
|
initPlayButtons();
|
||||||
initTopSongsView();
|
initTopSongsView();
|
||||||
initAlbumsView();
|
initAlbumsView();
|
||||||
|
|
||||||
|
|
@ -96,14 +102,21 @@ public class ArtistPageFragment extends Fragment {
|
||||||
bind.appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
bind.appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||||
if ((bind.collapsingToolbar.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(bind.collapsingToolbar))) {
|
if ((bind.collapsingToolbar.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(bind.collapsingToolbar))) {
|
||||||
bind.animToolbar.getNavigationIcon().setColorFilter(new BlendModeColorFilter(getResources().getColor(R.color.titleTextColor, null), BlendMode.SRC_ATOP));
|
bind.animToolbar.getNavigationIcon().setColorFilter(new BlendModeColorFilter(getResources().getColor(R.color.titleTextColor, null), BlendMode.SRC_ATOP));
|
||||||
bind.artistPageFabButton.setVisibility(View.GONE);
|
|
||||||
} else {
|
} else {
|
||||||
bind.animToolbar.getNavigationIcon().setColorFilter(new BlendModeColorFilter(getResources().getColor(R.color.white, null), BlendMode.SRC_ATOP));
|
bind.animToolbar.getNavigationIcon().setColorFilter(new BlendModeColorFilter(getResources().getColor(R.color.white, null), BlendMode.SRC_ATOP));
|
||||||
bind.artistPageFabButton.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bind.artistPageFabButton.setOnClickListener(v -> {
|
private void initBackdrop() {
|
||||||
|
CustomGlideRequest.Builder
|
||||||
|
.from(requireContext(), artistPageViewModel.getArtist().getBackdrop(), artistPageViewModel.getArtist().getBackdropBlurHash(), CustomGlideRequest.BACKDROP, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ARTIST_PIC)
|
||||||
|
.build()
|
||||||
|
.into(bind.artistBackdropImageView);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initPlayButtons() {
|
||||||
|
bind.artistPageShuffleButton.setOnClickListener(v -> {
|
||||||
List<Song> songs = artistPageViewModel.getArtistRandomSongList();
|
List<Song> songs = artistPageViewModel.getArtistRandomSongList();
|
||||||
|
|
||||||
if(songs.size() > 0) {
|
if(songs.size() > 0) {
|
||||||
|
|
@ -115,13 +128,24 @@ public class ArtistPageFragment extends Fragment {
|
||||||
}
|
}
|
||||||
else Toast.makeText(requireContext(), "Error retrieving artist's songs", Toast.LENGTH_SHORT).show();
|
else Toast.makeText(requireContext(), "Error retrieving artist's songs", Toast.LENGTH_SHORT).show();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
private void initBackdrop() {
|
bind.artistPageRadioButton.setOnClickListener(v -> SyncUtil.getInstantMix(requireContext(), new MediaCallback() {
|
||||||
CustomGlideRequest.Builder
|
@Override
|
||||||
.from(requireContext(), artistPageViewModel.getArtist().getBackdrop(), artistPageViewModel.getArtist().getBackdropBlurHash(), CustomGlideRequest.BACKDROP, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ARTIST_PIC)
|
public void onError(Exception exception) {
|
||||||
.build()
|
Toast.makeText(requireContext(), "Error retrieving artist's radio", Toast.LENGTH_SHORT).show();
|
||||||
.into(bind.artistBackdropImageView);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadMedia(List<?> media) {
|
||||||
|
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||||
|
List<Song> mix = queueRepository.insertMix((ArrayList<Song>) media);
|
||||||
|
|
||||||
|
activity.isBottomSheetInPeek(true);
|
||||||
|
activity.setBottomSheetMusicInfo(mix.get(0));
|
||||||
|
|
||||||
|
MusicPlayerRemote.openQueue(mix, 0, true);
|
||||||
|
}
|
||||||
|
}, SyncUtil.SONG, artistPageViewModel.getArtist().getId(), PreferenceUtil.getInstance(requireContext()).getInstantMixSongNumber()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTopSongsView() {
|
private void initTopSongsView() {
|
||||||
|
|
|
||||||
12
app/src/main/res/drawable/ic_feed.xml
Normal file
12
app/src/main/res/drawable/ic_feed.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@color/titleTextColor"
|
||||||
|
android:pathData="M6.18,17.82m-2.18,0a2.18,2.18 0,1 1,4.36 0a2.18,2.18 0,1 1,-4.36 0"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="@color/titleTextColor"
|
||||||
|
android:pathData="M4,4.44v2.83c7.03,0 12.73,5.7 12.73,12.73h2.83c0,-8.59 -6.97,-15.56 -15.56,-15.56zM4,10.1v2.83c3.9,0 7.07,3.17 7.07,7.07h2.83c0,-5.47 -4.43,-9.9 -9.9,-9.9z"/>
|
||||||
|
</vector>
|
||||||
|
|
@ -35,23 +35,6 @@
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
android:background="@drawable/gradient_backdrop_background_image"/>
|
android:background="@drawable/gradient_backdrop_background_image"/>
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/artist_page_fab_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_gravity="bottom|end"
|
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:contentDescription="Shuffle"
|
|
||||||
android:src="@drawable/ic_shuffle"
|
|
||||||
app:backgroundTint="@color/colorAccent"
|
|
||||||
app:fabSize="mini"
|
|
||||||
app:layout_anchor="@id/app_bar_layout"
|
|
||||||
app:layout_anchorGravity="bottom|end"
|
|
||||||
app:tint="@android:color/white" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/anim_toolbar"
|
android:id="@+id/anim_toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
@ -77,6 +60,62 @@
|
||||||
android:paddingTop="18dp"
|
android:paddingTop="18dp"
|
||||||
android:paddingBottom="@dimen/global_padding_bottom">
|
android:paddingBottom="@dimen/global_padding_bottom">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/upper_button_divider"
|
||||||
|
style="@style/Divider"
|
||||||
|
android:layout_marginStart="18dp"
|
||||||
|
android:layout_marginEnd="18dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/album_page_button_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="4dp">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/artist_page_shuffle_button"
|
||||||
|
style="@style/MainButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="4dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:backgroundTint="@color/buttonBackgroundColor"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="Shuffle"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
app:icon="@drawable/ic_shuffle"
|
||||||
|
app:iconGravity="textStart"
|
||||||
|
app:iconPadding="18dp"
|
||||||
|
app:iconTint="@color/darkIconColor" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/artist_page_radio_button"
|
||||||
|
style="@style/MainButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:backgroundTint="@color/buttonBackgroundColor"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="Radio"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
app:icon="@drawable/ic_feed"
|
||||||
|
app:iconGravity="textStart"
|
||||||
|
app:iconPadding="18dp"
|
||||||
|
app:iconTint="@color/darkIconColor" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/bottom_button_divider"
|
||||||
|
style="@style/Divider"
|
||||||
|
android:layout_marginStart="18dp"
|
||||||
|
android:layout_marginEnd="18dp"
|
||||||
|
android:layout_marginBottom="12dp"/>
|
||||||
|
|
||||||
<!-- Label and button -->
|
<!-- Label and button -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue