Browse Source

Prevent issue on queue item deletion. Should close #48.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
66c7915307
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 1
      app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt
  2. 2
      app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt
  3. 16
      app/src/main/java/com/github/apognu/otter/playback/QueueManager.kt

1
app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt

@ -45,7 +45,6 @@ import kotlinx.coroutines.Job @@ -45,7 +45,6 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlin.random.Random
class MainActivity : AppCompatActivity() {
enum class ResultCode(val code: Int) {

2
app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt

@ -253,8 +253,6 @@ class PlayerService : Service() { @@ -253,8 +253,6 @@ class PlayerService : Service() {
state(false)
player.release()
Otter.get().exoCache.release()
stopForeground(true)
stopSelf()

16
app/src/main/java/com/github/apognu/otter/playback/QueueManager.kt

@ -127,8 +127,24 @@ class QueueManager(val context: Context) { @@ -127,8 +127,24 @@ class QueueManager(val context: Context) {
fun remove(track: Track) {
metadata.indexOf(track).let {
if (it < 0) {
return
}
datasources.removeMediaSource(it)
metadata.removeAt(it)
if (it == current) {
CommandBus.send(Command.NextTrack)
}
if (it < current) {
current--
}
}
if (metadata.isEmpty()) {
current = -1
}
persist()

Loading…
Cancel
Save