Scroll QueueFragment on shuffle toggle
Scroll QueueFragment to the top when shuffle is toggled so that it does not flip out as much as it would otherwise.
This commit is contained in:
@@ -52,7 +52,7 @@ class MainActivity : AppCompatActivity() {
|
||||
// Since the activity is set to singleInstance [Given that there's only MainActivity]
|
||||
// We have to manually push the intent whenever we get one so that the fragments
|
||||
// can catch any file intents
|
||||
// TODO: Improve this dumb chain system in one way or another
|
||||
// TODO: If possible try to make this system completely
|
||||
setIntent(intent)
|
||||
}
|
||||
|
||||
|
||||
@@ -68,13 +68,14 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
|
||||
val userQueue: LiveData<MutableList<Song>> get() = mUserQueue
|
||||
/** The current [PlaybackMode] that also determines the queue */
|
||||
val mode: LiveData<PlaybackMode> get() = mMode
|
||||
|
||||
/** Whether playback is originating from the user-generated queue or not */
|
||||
val isInUserQueue: LiveData<Boolean> = mIsInUserQueue
|
||||
|
||||
val isPlaying: LiveData<Boolean> get() = mIsPlaying
|
||||
val isShuffling: LiveData<Boolean> get() = mIsShuffling
|
||||
/** The current repeat mode, see [LoopMode] for more information */
|
||||
val loopMode: LiveData<LoopMode> get() = mLoopMode
|
||||
|
||||
val isSeeking: LiveData<Boolean> get() = mIsSeeking
|
||||
val canAnimate: Boolean get() = mCanAnimate
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ class QueueFragment : Fragment() {
|
||||
val callback = QueueDragCallback(playbackModel)
|
||||
val helper = ItemTouchHelper(callback)
|
||||
val queueAdapter = QueueAdapter(helper, playbackModel)
|
||||
var lastShuffle = playbackModel.isShuffling.value
|
||||
|
||||
callback.addQueueAdapter(queueAdapter)
|
||||
|
||||
@@ -96,14 +97,22 @@ class QueueFragment : Fragment() {
|
||||
queueAdapter.submitList(createQueueData())
|
||||
}
|
||||
|
||||
playbackModel.isShuffling.observe(viewLifecycleOwner) {
|
||||
if (it != lastShuffle) {
|
||||
lastShuffle = it
|
||||
|
||||
binding.queueRecycler.scrollToPosition(0)
|
||||
}
|
||||
}
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
// QueueFragment shouldn't be handling file intents, as the effects it has on the recycler
|
||||
// are really weird.
|
||||
// QueueFragment shouldn't be handling file intents as it will cause the queue recycler
|
||||
// to flip out
|
||||
if (shouldHandleFileIntent()) {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user