mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 09:33:33 +00:00
Added a shuffle button in the artist's fragment
This commit is contained in:
parent
a871d37781
commit
1106e34250
4 changed files with 43 additions and 7 deletions
|
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
|
@ -12,15 +13,20 @@ import androidx.fragment.app.Fragment;
|
|||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.AlbumArtistPageAdapter;
|
||||
import com.cappielloantonio.play.adapter.SongResultSearchAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentArtistPageBinding;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.helper.MusicPlayerRemote;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||
import com.cappielloantonio.play.viewmodel.ArtistPageViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ArtistPageFragment extends Fragment {
|
||||
|
||||
private FragmentArtistPageBinding bind;
|
||||
|
|
@ -93,6 +99,19 @@ public class ArtistPageFragment extends Fragment {
|
|||
bind.animToolbar.getNavigationIcon().setColorFilter(getResources().getColor(R.color.white, null), PorterDuff.Mode.SRC_ATOP);
|
||||
}
|
||||
});
|
||||
|
||||
bind.artistPageFabButton.setOnClickListener(v -> {
|
||||
List<Song> songs = artistPageViewModel.getArtistRandomSongList();
|
||||
|
||||
if(songs.size() > 0) {
|
||||
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||
queueRepository.insertAllAndStartNew(songs);
|
||||
|
||||
MusicPlayerRemote.openQueue(songs, 0, true);
|
||||
((MainActivity) requireActivity()).isBottomSheetInPeek(true);
|
||||
}
|
||||
else Toast.makeText(requireContext(), "Error retrieving artist's songs", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
|
||||
private void initBackdrop() {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public class ArtistPageViewModel extends AndroidViewModel {
|
|||
private SongRepository songRepository;
|
||||
private AlbumRepository albumRepository;
|
||||
|
||||
private List<Song> randomList;
|
||||
private LiveData<List<Song>> songList;
|
||||
private LiveData<List<Album>> albumList;
|
||||
|
||||
|
|
@ -35,6 +36,11 @@ public class ArtistPageViewModel extends AndroidViewModel {
|
|||
return albumList;
|
||||
}
|
||||
|
||||
public List<Song> getArtistRandomSongList() {
|
||||
randomList = songRepository.getArtistListLiveRandomSong(artist.id);
|
||||
return randomList;
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getArtistTopSongList() {
|
||||
songList = songRepository.getArtistListLiveTopSongSample(artist.id);
|
||||
return songList;
|
||||
|
|
|
|||
|
|
@ -29,12 +29,21 @@
|
|||
android:scaleType="centerCrop"
|
||||
app:layout_collapseMode="parallax" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/appbar_header_height"
|
||||
android:layout_gravity="top"
|
||||
android:fitsSystemWindows="true"
|
||||
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_gravity="bottom|end"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:src="@drawable/ic_shuffle"
|
||||
app:backgroundTint="@color/colorAccent"
|
||||
app:tint="@android:color/white"
|
||||
app:fabSize="normal"
|
||||
app:layout_anchor="@id/app_bar_layout"
|
||||
app:layout_anchorGravity="bottom|end"
|
||||
android:layout_margin="16dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:contentDescription="Shuffle"/>
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/anim_toolbar"
|
||||
|
|
@ -47,6 +56,7 @@
|
|||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
|
||||
<dimen name="appbar_header_height">384dp</dimen>
|
||||
<dimen name="appbar_header_height">296dp</dimen>
|
||||
|
||||
<dimen name="activity_margin_content">24dp</dimen>
|
||||
|
||||
<dimen name="bottom_sheet_peek_height">56dp</dimen>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue