- Made deleting of messages and chats safe.
This commit is contained in:
@ -31,7 +31,8 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
||||
}
|
||||
|
||||
fun clear(aor: String) {
|
||||
BaresipService.history = ArrayList(BaresipService.history.filter{it.aor != aor})
|
||||
val it = BaresipService.history.iterator()
|
||||
while (it.hasNext()) if (it.next().aor == aor) it.remove()
|
||||
}
|
||||
|
||||
fun aorHistorySize(aor: String): Int {
|
||||
|
||||
@ -158,7 +158,7 @@ class ChatsActivity: AppCompatActivity() {
|
||||
deleteDialog.setMessage(String.format(getString(R.string.delete_chats_alert),
|
||||
aor.substringAfter(":")))
|
||||
deleteDialog.setPositiveButton(getText(R.string.delete)) { dialog, _ ->
|
||||
BaresipService.messages = ArrayList(BaresipService.messages.filter{it.aor != aor})
|
||||
Message.clear(aor)
|
||||
Message.saveMessages()
|
||||
uaMessages.clear()
|
||||
clAdapter.notifyDataSetChanged()
|
||||
|
||||
@ -31,6 +31,11 @@ class Message(val aor: String, val peerUri: String, val message: String, val tim
|
||||
BaresipService.messages.removeAt(firstIndex)
|
||||
}
|
||||
|
||||
fun clear(aor: String) {
|
||||
val it = BaresipService.messages.iterator()
|
||||
while (it.hasNext()) if (it.next().aor == aor) it.remove()
|
||||
}
|
||||
|
||||
fun saveMessages() {
|
||||
val file = File(BaresipService.filesPath, "messages")
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user