Clear queue on logout.
This commit is contained in:
parent
5c1498bb95
commit
eac875b9cb
|
@ -12,6 +12,8 @@ import androidx.preference.PreferenceFragmentCompat
|
|||
import androidx.preference.SeekBarPreference
|
||||
import com.github.apognu.otter.R
|
||||
import com.github.apognu.otter.utils.AppContext
|
||||
import com.github.apognu.otter.utils.Command
|
||||
import com.github.apognu.otter.utils.CommandBus
|
||||
import com.preference.PowerPreference
|
||||
|
||||
class SettingsActivity : AppCompatActivity() {
|
||||
|
@ -69,6 +71,8 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP
|
|||
|
||||
context.cacheDir.deleteRecursively()
|
||||
|
||||
CommandBus.send(Command.ClearQueue)
|
||||
|
||||
activity?.setResult(MainActivity.ResultCode.LOGOUT.code)
|
||||
activity?.finish()
|
||||
}
|
||||
|
|
|
@ -172,6 +172,8 @@ class PlayerService : Service() {
|
|||
is Command.NextTrack -> player.next()
|
||||
is Command.PreviousTrack -> previousTrack()
|
||||
is Command.Seek -> progress(message.progress)
|
||||
|
||||
is Command.ClearQueue -> queue.clear()
|
||||
}
|
||||
|
||||
if (player.playWhenReady) {
|
||||
|
|
|
@ -154,4 +154,10 @@ class QueueManager(val context: Context) {
|
|||
|
||||
return metadata.getOrNull(current)
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
metadata = mutableListOf()
|
||||
datasources.clear()
|
||||
current = -1
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ sealed class Command {
|
|||
class ReplaceQueue(val queue: List<Track>) : Command()
|
||||
class RemoveFromQueue(val track: Track) : Command()
|
||||
class MoveFromQueue(val oldPosition: Int, val newPosition: Int) : Command()
|
||||
object ClearQueue : Command()
|
||||
|
||||
class PlayTrack(val index: Int) : Command()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue