From c0f1b9423f98147fdb3fc7081ea3bfca836f3be8 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Thu, 5 Jan 2023 10:04:19 -0700 Subject: [PATCH] music: band-aid queue move issues Band-aid certain types of queue moves that will fail to cauase the index to correct. Just do this by assuming all queue moves are swaps and then forgetting about it. I'll need to figure out how to "properly" do this eventually. --- .../org/oxycblt/auxio/playback/queue/QueueViewModel.kt | 1 - .../java/org/oxycblt/auxio/playback/state/Queue.kt | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueViewModel.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueViewModel.kt index 2141a47bd..5c5e5d8d3 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueViewModel.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueViewModel.kt @@ -24,7 +24,6 @@ import org.oxycblt.auxio.music.MusicParent import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.playback.state.PlaybackStateManager import org.oxycblt.auxio.playback.state.Queue -import org.oxycblt.auxio.util.logD /** * A [ViewModel] that manages the current queue state and allows navigation through the queue. diff --git a/app/src/main/java/org/oxycblt/auxio/playback/state/Queue.kt b/app/src/main/java/org/oxycblt/auxio/playback/state/Queue.kt index 0c1551b9c..333d5e189 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/state/Queue.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/state/Queue.kt @@ -170,6 +170,7 @@ class Queue { * mutated. */ fun move(src: Int, dst: Int): ChangeResult { + if (shuffledMapping.isNotEmpty()) { // Move songs only in the shuffled mapping. There is no sane analogous form of // this for the ordered mapping. @@ -179,19 +180,16 @@ class Queue { orderedMapping.add(dst, orderedMapping.removeAt(src)) } + // TODO: I really need to figure out how to get non-swap moves working. return when (index) { - // Moving the currently playing song. src -> { index = dst ChangeResult.INDEX } - // Index was ahead of moved song but not ahead of it's destination position. - // This makes it functionally a removal, so update the index to preserve consistency. - in (src + 1)..dst -> { - index -= 1 + dst -> { + index = src ChangeResult.INDEX } - // Nothing to do. else -> ChangeResult.MAPPING } }