mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-01-30 09:04:50 +01:00
Retain scroll position when deleting messages
Removed the call to `refreshMessages()` as it's not really needed here and also because it'll reset the scroll position in some cases
This commit is contained in:
parent
c6d453f5ab
commit
398c2237bc
@ -408,6 +408,7 @@ class ThreadActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun deleteMessages(messagesToRemove: List<Message>) {
|
||||
val deletePosition = threadItems.indexOf(messagesToRemove.first())
|
||||
messages.removeAll(messagesToRemove.toSet())
|
||||
threadItems = getThreadItems()
|
||||
|
||||
@ -416,7 +417,7 @@ class ThreadActivity : SimpleActivity() {
|
||||
finish()
|
||||
} else {
|
||||
getOrCreateThreadAdapter().apply {
|
||||
updateMessages(threadItems)
|
||||
updateMessages(threadItems, scrollPosition = deletePosition)
|
||||
finishActMode()
|
||||
}
|
||||
}
|
||||
@ -441,7 +442,6 @@ class ThreadActivity : SimpleActivity() {
|
||||
updateScheduledMessagesThreadId(messages, fakeThreadId)
|
||||
threadId = fakeThreadId
|
||||
}
|
||||
refreshMessages()
|
||||
}
|
||||
|
||||
private fun fetchNextMessages() {
|
||||
|
@ -230,7 +230,9 @@ class ThreadAdapter(
|
||||
fun updateMessages(newMessages: ArrayList<ThreadItem>, scrollPosition: Int = newMessages.lastIndex) {
|
||||
val latestMessages = newMessages.toMutableList()
|
||||
submitList(latestMessages) {
|
||||
recyclerView.scrollToPosition(scrollPosition)
|
||||
if (scrollPosition != -1) {
|
||||
recyclerView.scrollToPosition(scrollPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user