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:
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.music.Song
|
||||||
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
||||||
import org.oxycblt.auxio.playback.state.Queue
|
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.
|
* A [ViewModel] that manages the current queue state and allows navigation through the queue.
|
||||||
|
|
|
@ -170,6 +170,7 @@ class Queue {
|
||||||
* mutated.
|
* mutated.
|
||||||
*/
|
*/
|
||||||
fun move(src: Int, dst: Int): ChangeResult {
|
fun move(src: Int, dst: Int): ChangeResult {
|
||||||
|
|
||||||
if (shuffledMapping.isNotEmpty()) {
|
if (shuffledMapping.isNotEmpty()) {
|
||||||
// Move songs only in the shuffled mapping. There is no sane analogous form of
|
// Move songs only in the shuffled mapping. There is no sane analogous form of
|
||||||
// this for the ordered mapping.
|
// this for the ordered mapping.
|
||||||
|
@ -179,19 +180,16 @@ class Queue {
|
||||||
orderedMapping.add(dst, orderedMapping.removeAt(src))
|
orderedMapping.add(dst, orderedMapping.removeAt(src))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: I really need to figure out how to get non-swap moves working.
|
||||||
return when (index) {
|
return when (index) {
|
||||||
// Moving the currently playing song.
|
|
||||||
src -> {
|
src -> {
|
||||||
index = dst
|
index = dst
|
||||||
ChangeResult.INDEX
|
ChangeResult.INDEX
|
||||||
}
|
}
|
||||||
// Index was ahead of moved song but not ahead of it's destination position.
|
dst -> {
|
||||||
// This makes it functionally a removal, so update the index to preserve consistency.
|
index = src
|
||||||
in (src + 1)..dst -> {
|
|
||||||
index -= 1
|
|
||||||
ChangeResult.INDEX
|
ChangeResult.INDEX
|
||||||
}
|
}
|
||||||
// Nothing to do.
|
|
||||||
else -> ChangeResult.MAPPING
|
else -> ChangeResult.MAPPING
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue