mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-22 09:04:32 +01:00
Bug Fixes
This commit is contained in:
parent
79ad318264
commit
6432c4fbc0
@ -62,7 +62,7 @@ class ForegroundService : LifecycleService() {
|
|||||||
private val logger: Kermit by inject()
|
private val logger: Kermit by inject()
|
||||||
private val dir: Dir by inject()
|
private val dir: Dir by inject()
|
||||||
|
|
||||||
private var messageList = MutableList(5) { emptyMessage }
|
private var messageList = java.util.Collections.synchronizedList(MutableList(5) { emptyMessage })
|
||||||
private var wakeLock: PowerManager.WakeLock? = null
|
private var wakeLock: PowerManager.WakeLock? = null
|
||||||
private var isServiceStarted = false
|
private var isServiceStarted = false
|
||||||
private val cancelIntent: PendingIntent by lazy {
|
private val cancelIntent: PendingIntent by lazy {
|
||||||
@ -275,18 +275,24 @@ class ForegroundService : LifecycleService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addToNotification(message: Message) {
|
private fun addToNotification(message: Message) {
|
||||||
messageList.add(message)
|
synchronized(messageList) {
|
||||||
|
messageList.add(message)
|
||||||
|
}
|
||||||
updateNotification()
|
updateNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun removeFromNotification(message: Message) {
|
private fun removeFromNotification(message: Message) {
|
||||||
messageList.removeAll { it.title == message.title }
|
synchronized(messageList) {
|
||||||
|
messageList.removeAll { it.title == message.title }
|
||||||
|
}
|
||||||
updateNotification()
|
updateNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateProgressInNotification(message: Message) {
|
private fun updateProgressInNotification(message: Message) {
|
||||||
val index = messageList.indexOfFirst { it.title == message.title }
|
synchronized(messageList) {
|
||||||
messageList[index] = message
|
val index = messageList.indexOfFirst { it.title == message.title }
|
||||||
|
messageList[index] = message
|
||||||
|
}
|
||||||
updateNotification()
|
updateNotification()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,4 +31,4 @@ fun Message.asString(): String {
|
|||||||
return "$statusString $title ${""/*progress*/}".trim()
|
return "$statusString $title ${""/*progress*/}".trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun List<Message>.getEmpty(): MutableList<Message> = MutableList(size) { emptyMessage }
|
fun List<Message>.getEmpty(): MutableList<Message> = java.util.Collections.synchronizedList(MutableList(size) { emptyMessage })
|
Loading…
Reference in New Issue
Block a user