playback: further pager cleanup
- Use Replace instead of Diff for now since that avoids the scroll state freaking out. In practice I'll likely need to radically refactor this system (AGAIN...) to make the queue updates 100% fine-grained, even during shuffling. - Remove the behaivor of staying paused on the next track. That's covered by #568.
This commit is contained in:
parent
243fb73f94
commit
94e2c3c3e4
5 changed files with 11 additions and 12 deletions
|
@ -175,7 +175,7 @@ class PlaybackPanelFragment :
|
|||
}
|
||||
|
||||
private fun updateQueue(queue: List<Song>) {
|
||||
coverAdapter?.update(queue, UpdateInstructions.Diff)
|
||||
coverAdapter?.update(queue, UpdateInstructions.Replace(0))
|
||||
}
|
||||
|
||||
private fun updateQueuePosition(position: Int) {
|
||||
|
@ -239,7 +239,7 @@ class PlaybackPanelFragment :
|
|||
// TODO
|
||||
}
|
||||
|
||||
private class OnCoverChangedCallback(private val viewModel: QueueViewModel) :
|
||||
private class OnCoverChangedCallback(private val queueViewModel: QueueViewModel) :
|
||||
OnPageChangeCallback() {
|
||||
|
||||
private var targetPosition = RecyclerView.NO_POSITION
|
||||
|
@ -253,8 +253,8 @@ class PlaybackPanelFragment :
|
|||
super.onPageScrollStateChanged(state)
|
||||
if (state == ViewPager2.SCROLL_STATE_IDLE &&
|
||||
targetPosition != RecyclerView.NO_POSITION &&
|
||||
targetPosition != viewModel.index.value) {
|
||||
viewModel.goto(targetPosition, playIfPaused = false)
|
||||
targetPosition != queueViewModel.index.value) {
|
||||
queueViewModel.goto(targetPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ class QueueFragment : ViewBindingFragment<FragmentQueueBinding>(), EditClickList
|
|||
}
|
||||
|
||||
override fun onClick(item: Song, viewHolder: RecyclerView.ViewHolder) {
|
||||
queueModel.goto(viewHolder.bindingAdapterPosition, playIfPaused = true)
|
||||
queueModel.goto(viewHolder.bindingAdapterPosition)
|
||||
}
|
||||
|
||||
override fun onPickUp(viewHolder: RecyclerView.ViewHolder) {
|
||||
|
|
|
@ -108,12 +108,12 @@ class QueueViewModel @Inject constructor(private val playbackManager: PlaybackSt
|
|||
* range.
|
||||
* @param playIfPaused Start playing after switching even if it currently is paused
|
||||
*/
|
||||
fun goto(adapterIndex: Int, playIfPaused: Boolean) {
|
||||
fun goto(adapterIndex: Int) {
|
||||
if (adapterIndex !in queue.value.indices) {
|
||||
return
|
||||
}
|
||||
logD("Going to position $adapterIndex in queue")
|
||||
playbackManager.goto(adapterIndex, playIfPaused || playbackManager.playerState.isPlaying)
|
||||
playbackManager.goto(adapterIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -120,9 +120,8 @@ interface PlaybackStateManager {
|
|||
* Play a [Song] at the given position in the queue.
|
||||
*
|
||||
* @param index The position of the [Song] in the queue to start playing.
|
||||
* @param play Whether to start playing after switching to target index
|
||||
*/
|
||||
fun goto(index: Int, play: Boolean)
|
||||
fun goto(index: Int)
|
||||
|
||||
/**
|
||||
* Add [Song]s to the top of the queue.
|
||||
|
@ -430,12 +429,12 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
|
|||
}
|
||||
|
||||
@Synchronized
|
||||
override fun goto(index: Int, play: Boolean) {
|
||||
override fun goto(index: Int) {
|
||||
val internalPlayer = internalPlayer ?: return
|
||||
if (queue.goto(index)) {
|
||||
logD("Moving to $index")
|
||||
notifyIndexMoved()
|
||||
internalPlayer.loadSong(queue.currentSong, play)
|
||||
internalPlayer.loadSong(queue.currentSong, true)
|
||||
} else {
|
||||
logW("$index was not in bounds, could not move to it")
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ constructor(
|
|||
}
|
||||
|
||||
override fun onSkipToQueueItem(id: Long) {
|
||||
playbackManager.goto(id.toInt(), true)
|
||||
playbackManager.goto(id.toInt())
|
||||
}
|
||||
|
||||
override fun onCustomAction(action: String?, extras: Bundle?) {
|
||||
|
|
Loading…
Reference in a new issue