mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-01-30 17:14:55 +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>) {
|
private fun deleteMessages(messagesToRemove: List<Message>) {
|
||||||
|
val deletePosition = threadItems.indexOf(messagesToRemove.first())
|
||||||
messages.removeAll(messagesToRemove.toSet())
|
messages.removeAll(messagesToRemove.toSet())
|
||||||
threadItems = getThreadItems()
|
threadItems = getThreadItems()
|
||||||
|
|
||||||
@ -416,7 +417,7 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
finish()
|
finish()
|
||||||
} else {
|
} else {
|
||||||
getOrCreateThreadAdapter().apply {
|
getOrCreateThreadAdapter().apply {
|
||||||
updateMessages(threadItems)
|
updateMessages(threadItems, scrollPosition = deletePosition)
|
||||||
finishActMode()
|
finishActMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,7 +442,6 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
updateScheduledMessagesThreadId(messages, fakeThreadId)
|
updateScheduledMessagesThreadId(messages, fakeThreadId)
|
||||||
threadId = fakeThreadId
|
threadId = fakeThreadId
|
||||||
}
|
}
|
||||||
refreshMessages()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchNextMessages() {
|
private fun fetchNextMessages() {
|
||||||
|
@ -230,7 +230,9 @@ class ThreadAdapter(
|
|||||||
fun updateMessages(newMessages: ArrayList<ThreadItem>, scrollPosition: Int = newMessages.lastIndex) {
|
fun updateMessages(newMessages: ArrayList<ThreadItem>, scrollPosition: Int = newMessages.lastIndex) {
|
||||||
val latestMessages = newMessages.toMutableList()
|
val latestMessages = newMessages.toMutableList()
|
||||||
submitList(latestMessages) {
|
submitList(latestMessages) {
|
||||||
recyclerView.scrollToPosition(scrollPosition)
|
if (scrollPosition != -1) {
|
||||||
|
recyclerView.scrollToPosition(scrollPosition)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user