- all user interface unrelated data is now kept in baresip service
allowing proper recovery in case Android kills other activities - many other improvements and bug fixes
This commit is contained in:
@@ -1,7 +1,38 @@
|
||||
package com.tutpro.baresip
|
||||
|
||||
import java.io.Serializable
|
||||
import java.io.*
|
||||
import java.util.ArrayList
|
||||
|
||||
class Message(val aor: String, val peerUri: String, var direction: Int, val message: String,
|
||||
val timeStamp: Long, var new: Boolean): Serializable {
|
||||
|
||||
companion object {
|
||||
|
||||
val MESSAGE_HISTORY_SIZE = 100
|
||||
|
||||
fun messages(): ArrayList<Message> {
|
||||
return BaresipService.messages
|
||||
}
|
||||
|
||||
fun messages(messages: ArrayList<Message>) {
|
||||
BaresipService.messages = messages
|
||||
}
|
||||
|
||||
fun add(message: Message) {
|
||||
BaresipService.messages.add(message)
|
||||
var count = 0
|
||||
var firstIndex = -1
|
||||
for (i in BaresipService.messages.indices)
|
||||
if (BaresipService.messages[i].aor == message.aor) {
|
||||
if (count == 0) firstIndex = i
|
||||
count++
|
||||
if (count > MESSAGE_HISTORY_SIZE) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if (count > MESSAGE_HISTORY_SIZE)
|
||||
BaresipService.messages.removeAt(firstIndex)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user