playback: fix remember shuffle regression
Fix a regression that broke the Remember Shuffle option.
This commit is contained in:
parent
b041fe68d0
commit
787a0df595
3 changed files with 13 additions and 4 deletions
|
@ -91,8 +91,7 @@ class PlaybackViewModel(application: Application) :
|
||||||
|
|
||||||
/** Play a [song] with the [mode] specified, */
|
/** Play a [song] with the [mode] specified, */
|
||||||
fun play(song: Song, mode: PlaybackMode) {
|
fun play(song: Song, mode: PlaybackMode) {
|
||||||
playbackManager.play(
|
playbackManager.play(song, mode, settings)
|
||||||
song, settings.keepShuffle && playbackManager.isPlaying, mode, settings)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -148,7 +148,7 @@ class PlaybackStateManager private constructor() {
|
||||||
* Play a [song].
|
* Play a [song].
|
||||||
* @param playbackMode The [PlaybackMode] to construct the queue off of.
|
* @param playbackMode The [PlaybackMode] to construct the queue off of.
|
||||||
*/
|
*/
|
||||||
fun play(song: Song, shuffle: Boolean, playbackMode: PlaybackMode, settings: Settings) {
|
fun play(song: Song, playbackMode: PlaybackMode, settings: Settings) {
|
||||||
val library = musicStore.library ?: return
|
val library = musicStore.library ?: return
|
||||||
|
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
|
@ -160,7 +160,7 @@ class PlaybackStateManager private constructor() {
|
||||||
PlaybackMode.IN_GENRE -> song.genre
|
PlaybackMode.IN_GENRE -> song.genre
|
||||||
}
|
}
|
||||||
|
|
||||||
applyNewQueue(library, settings, shuffle, song)
|
applyNewQueue(library, settings, settings.keepShuffle && isShuffled, song)
|
||||||
seekTo(0)
|
seekTo(0)
|
||||||
notifyNewPlayback()
|
notifyNewPlayback()
|
||||||
notifyShuffledChanged()
|
notifyShuffledChanged()
|
||||||
|
|
|
@ -169,17 +169,27 @@ fun Fragment.launch(
|
||||||
viewLifecycleOwner.lifecycleScope.launch { viewLifecycleOwner.repeatOnLifecycle(state, block) }
|
viewLifecycleOwner.lifecycleScope.launch { viewLifecycleOwner.repeatOnLifecycle(state, block) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut to generate a AndroidViewModel [T] without having to specify the bloated factory syntax.
|
||||||
|
*/
|
||||||
inline fun <reified T : AndroidViewModel> Fragment.androidViewModels() =
|
inline fun <reified T : AndroidViewModel> Fragment.androidViewModels() =
|
||||||
viewModels<T> { ViewModelProvider.AndroidViewModelFactory(requireActivity().application) }
|
viewModels<T> { ViewModelProvider.AndroidViewModelFactory(requireActivity().application) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut to generate a AndroidViewModel [T] without having to specify the bloated factory syntax.
|
||||||
|
*/
|
||||||
inline fun <reified T : AndroidViewModel> AppCompatActivity.androidViewModels() =
|
inline fun <reified T : AndroidViewModel> AppCompatActivity.androidViewModels() =
|
||||||
viewModels<T> { ViewModelProvider.AndroidViewModelFactory(application) }
|
viewModels<T> { ViewModelProvider.AndroidViewModelFactory(application) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut to generate a AndroidViewModel [T] without having to specify the bloated factory syntax.
|
||||||
|
*/
|
||||||
inline fun <reified T : AndroidViewModel> Fragment.androidActivityViewModels() =
|
inline fun <reified T : AndroidViewModel> Fragment.androidActivityViewModels() =
|
||||||
activityViewModels<T> {
|
activityViewModels<T> {
|
||||||
ViewModelProvider.AndroidViewModelFactory(requireActivity().application)
|
ViewModelProvider.AndroidViewModelFactory(requireActivity().application)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Shortcut to get the [Application] from an [AndroidViewModel] */
|
||||||
val AndroidViewModel.application: Application
|
val AndroidViewModel.application: Application
|
||||||
get() = getApplication()
|
get() = getApplication()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue