Add shuffle buttons to Detail Fragments
Add shuffle buttons to AlbumDetailFragment & ArtistDetailFragment.
This commit is contained in:
parent
c422071e93
commit
00667151dc
4 changed files with 54 additions and 6 deletions
|
@ -79,7 +79,7 @@ class PlaybackViewModel : ViewModel() {
|
|||
PlaybackMode.IN_ALBUM -> song.album
|
||||
}
|
||||
|
||||
if (isShuffling.value!!) {
|
||||
if (mIsShuffling.value!!) {
|
||||
genShuffle(true)
|
||||
} else {
|
||||
resetShuffle()
|
||||
|
@ -100,6 +100,12 @@ class PlaybackViewModel : ViewModel() {
|
|||
mCurrentParent.value = album
|
||||
mIsShuffling.value = isShuffled
|
||||
mCurrentMode.value = PlaybackMode.IN_ALBUM
|
||||
|
||||
if (mIsShuffling.value!!) {
|
||||
genShuffle(false)
|
||||
} else {
|
||||
resetShuffle()
|
||||
}
|
||||
}
|
||||
|
||||
fun play(artist: Artist, isShuffled: Boolean) {
|
||||
|
@ -114,6 +120,12 @@ class PlaybackViewModel : ViewModel() {
|
|||
mCurrentParent.value = artist
|
||||
mIsShuffling.value = isShuffled
|
||||
mCurrentMode.value = PlaybackMode.IN_ARTIST
|
||||
|
||||
if (mIsShuffling.value!!) {
|
||||
genShuffle(false)
|
||||
} else {
|
||||
resetShuffle()
|
||||
}
|
||||
}
|
||||
|
||||
// Update the current duration using a SeekBar progress
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
<solid android:color="@android:color/white" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
</ripple>
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
android:layout_marginEnd="@dimen/margin_medium"
|
||||
android:maxLines="1"
|
||||
android:text="@{album.name}"
|
||||
android:ellipsize="end"
|
||||
app:autoSizeMaxTextSize="@dimen/text_size_header_max"
|
||||
app:autoSizeMinTextSize="@dimen/text_size_min"
|
||||
app:autoSizeStepGranularity="@dimen/text_size_increment"
|
||||
|
@ -108,12 +109,30 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="@dimen/margin_tiny"
|
||||
android:layout_marginEnd="@dimen/margin_medium"
|
||||
android:layout_marginEnd="@dimen/margin_tiny"
|
||||
android:background="@drawable/ui_circular_button"
|
||||
android:backgroundTint="?android:attr/colorPrimary"
|
||||
android:contentDescription="@string/description_play"
|
||||
android:src="@drawable/ic_play"
|
||||
android:onClick="@{() -> playbackModel.play(album, false)}"
|
||||
android:src="@drawable/ic_play"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/album_details"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toStartOf="@+id/album_shuffle"
|
||||
app:layout_constraintTop_toTopOf="@+id/album_artist" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/album_shuffle"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginEnd="@dimen/margin_medium"
|
||||
android:layout_marginTop="@dimen/margin_tiny"
|
||||
android:background="@drawable/ui_circular_button"
|
||||
android:backgroundTint="?android:attr/colorPrimary"
|
||||
android:contentDescription="@string/description_play"
|
||||
android:onClick="@{() -> playbackModel.play(album, true)}"
|
||||
android:src="@drawable/ic_shuffle_small"
|
||||
android:tint="@color/background"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/album_details"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="@dimen/margin_tiny"
|
||||
android:layout_marginEnd="@dimen/margin_medium"
|
||||
android:layout_marginEnd="@dimen/margin_tiny"
|
||||
android:background="@drawable/ui_circular_button"
|
||||
android:backgroundTint="?android:attr/colorPrimary"
|
||||
android:contentDescription="@string/description_play"
|
||||
|
@ -112,6 +112,24 @@
|
|||
android:onClick="@{() -> playbackModel.play(artist, false)}"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/artist_counts"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toStartOf="@+id/album_shuffle"
|
||||
app:layout_constraintTop_toTopOf="@+id/artist_genre" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/album_shuffle"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginEnd="@dimen/margin_medium"
|
||||
android:layout_marginTop="@dimen/margin_tiny"
|
||||
android:background="@drawable/ui_circular_button"
|
||||
android:backgroundTint="?android:attr/colorPrimary"
|
||||
android:contentDescription="@string/description_play"
|
||||
android:onClick="@{() -> playbackModel.play(artist, true)}"
|
||||
android:src="@drawable/ic_shuffle_small"
|
||||
android:tint="@color/background"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/artist_counts"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/artist_genre" />
|
||||
|
||||
|
@ -166,5 +184,4 @@
|
|||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
Loading…
Reference in a new issue