mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Added Play and Shuffle button in PlaylistPage
This commit is contained in:
parent
5ce5ef4d38
commit
1598e2964f
4 changed files with 137 additions and 28 deletions
|
|
@ -55,6 +55,7 @@ public class AlbumPageFragment extends Fragment {
|
|||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
initAppBar();
|
||||
initMusicButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -113,6 +114,18 @@ public class AlbumPageFragment extends Fragment {
|
|||
bind.albumArtistLabel.setText(albumPageViewModel.getAlbum().getArtistName());
|
||||
bind.albumReleaseYearLabel.setText(albumPageViewModel.getAlbum().getYear() != 0 ? String.valueOf(albumPageViewModel.getAlbum().getYear()) : "");
|
||||
|
||||
bind.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
if ((bind.albumInfoSector.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(bind.animToolbar))) {
|
||||
bind.animToolbar.setTitle(albumPageViewModel.getAlbum().getTitle());
|
||||
} else {
|
||||
bind.animToolbar.setTitle("Album");
|
||||
}
|
||||
});
|
||||
|
||||
bind.animToolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||
}
|
||||
|
||||
private void initMusicButton() {
|
||||
albumPageViewModel.getAlbumSongLiveList().observe(requireActivity(), songs -> {
|
||||
if(bind != null) {
|
||||
bind.albumPagePlayButton.setOnClickListener(v -> {
|
||||
|
|
@ -138,16 +151,6 @@ public class AlbumPageFragment extends Fragment {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
bind.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
if ((bind.albumInfoSector.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(bind.animToolbar))) {
|
||||
bind.animToolbar.setTitle(albumPageViewModel.getAlbum().getTitle());
|
||||
} else {
|
||||
bind.animToolbar.setTitle("Album");
|
||||
}
|
||||
});
|
||||
|
||||
bind.animToolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
|
||||
}
|
||||
|
||||
private void initBackCover() {
|
||||
|
|
|
|||
|
|
@ -12,13 +12,18 @@ 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.SongResultSearchAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentPlaylistPageBinding;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.service.MusicPlayerRemote;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.viewmodel.PlaylistPageViewModel;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class PlaylistPageFragment extends Fragment {
|
||||
|
||||
private FragmentPlaylistPageBinding bind;
|
||||
|
|
@ -32,6 +37,7 @@ public class PlaylistPageFragment extends Fragment {
|
|||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
initAppBar();
|
||||
initMusicButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -83,6 +89,34 @@ public class PlaylistPageFragment extends Fragment {
|
|||
});
|
||||
}
|
||||
|
||||
private void initMusicButton() {
|
||||
playlistPageViewModel.getPlaylistSongList().observe(requireActivity(), songs -> {
|
||||
if(bind != null) {
|
||||
bind.playlistPagePlayButton.setOnClickListener(v -> {
|
||||
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||
queueRepository.insertAllAndStartNew(songs);
|
||||
|
||||
activity.isBottomSheetInPeek(true);
|
||||
activity.setBottomSheetMusicInfo(songs.get(0));
|
||||
|
||||
MusicPlayerRemote.openQueue(songs, 0, true);
|
||||
});
|
||||
|
||||
bind.playlistPageShuffleButton.setOnClickListener(v -> {
|
||||
Collections.shuffle(songs);
|
||||
|
||||
QueueRepository queueRepository = new QueueRepository(App.getInstance());
|
||||
queueRepository.insertAllAndStartNew(songs);
|
||||
|
||||
activity.isBottomSheetInPeek(true);
|
||||
activity.setBottomSheetMusicInfo(songs.get(0));
|
||||
|
||||
MusicPlayerRemote.openQueue(songs, 0, true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initBackCover() {
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), playlistPageViewModel.getPlaylist().getPrimary(), playlistPageViewModel.getPlaylist().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY, CustomGlideRequest.ALBUM_PIC)
|
||||
|
|
@ -91,11 +125,11 @@ public class PlaylistPageFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void initSongsView() {
|
||||
bind.songRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.songRecyclerView.setHasFixedSize(true);
|
||||
bind.playlistRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
bind.playlistRecyclerView.setHasFixedSize(true);
|
||||
|
||||
songResultSearchAdapter = new SongResultSearchAdapter(activity, requireContext(), getChildFragmentManager());
|
||||
bind.songRecyclerView.setAdapter(songResultSearchAdapter);
|
||||
bind.playlistRecyclerView.setAdapter(songResultSearchAdapter);
|
||||
playlistPageViewModel.getPlaylistSongList().observe(requireActivity(), songs -> {
|
||||
songResultSearchAdapter.setItems(songs);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,13 +46,83 @@
|
|||
</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"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="18dp"
|
||||
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/playlist_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/playlist_page_play_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="Play"
|
||||
android:textAllCaps="false"
|
||||
app:icon="@drawable/ic_play"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="18dp"
|
||||
app:iconTint="@color/darkIconColor" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/playlist_page_shuffle_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="Shuffle"
|
||||
android:textAllCaps="false"
|
||||
app:icon="@drawable/ic_shuffle"
|
||||
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"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/song_recycler_view"
|
||||
android:id="@+id/playlist_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="18dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:paddingBottom="@dimen/global_padding_bottom"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
@ -28,8 +28,8 @@
|
|||
android:id="@+id/album_info_sector"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="172dp"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
|
||||
android:clipChildren="false">
|
||||
android:clipChildren="false"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_title_label"
|
||||
|
|
@ -50,26 +50,28 @@
|
|||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:background="@drawable/ic_play"
|
||||
android:backgroundTint="@color/bottomNavIconColor"
|
||||
android:foreground="?android:attr/selectableItemBackgroundBorderless"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/song_list_shuffle_image_view"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:background="@drawable/ic_shuffle"
|
||||
android:backgroundTint="@color/bottomNavIconColor"
|
||||
android:foreground="?android:attr/selectableItemBackgroundBorderless"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_list_play_image_view"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_list_play_image_view" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue