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.
This commit is contained in:
Alexander Capehart
2023-01-05 10:04:19 -07:00
parent 41dd9bf695
commit c0f1b9423f
2 changed files with 4 additions and 7 deletions
@@ -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.
@@ -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
}
}