move saving of conversation list scroll-position to onPause

otherwise, it's would not work when just reopening the app from background

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2025-07-16 15:58:44 +02:00
parent 71e454d135
commit 38b5098492
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -345,6 +345,16 @@ class ConversationsListActivity :
showSearchOrToolbar() showSearchOrToolbar()
} }
override fun onPause() {
super.onPause()
val firstVisible = layoutManager?.findFirstVisibleItemPosition() ?: 0
val firstItem = adapter?.getItem(firstVisible)
val firstTop = (firstItem as ConversationItem).mHolder?.itemView?.top
val firstOffset = firstTop?.minus(CONVERSATION_ITEM_HEIGHT) ?: 0
appPreferences.setConversationListPositionAndOffset(firstVisible, firstOffset)
}
// if edge to edge is used, add an empty item at the bottom of the list // if edge to edge is used, add an empty item at the bottom of the list
@Suppress("MagicNumber") @Suppress("MagicNumber")
private fun addEmptyItemForEdgeToEdgeIfNecessary() { private fun addEmptyItemForEdgeToEdgeIfNecessary() {
@ -1881,12 +1891,6 @@ class ConversationsListActivity :
bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId) bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId)
selectedMessageId = null selectedMessageId = null
} }
val firstVisible = layoutManager?.findFirstVisibleItemPosition() ?: 0
val firstItem = adapter?.getItem(firstVisible)
val firstTop = (firstItem as ConversationItem).mHolder?.itemView?.top
val firstOffset = firstTop?.minus(CONVERSATION_ITEM_HEIGHT) ?: 0
appPreferences.setConversationListPositionAndOffset(firstVisible, firstOffset)
val intent = Intent(context, ChatActivity::class.java) val intent = Intent(context, ChatActivity::class.java)
intent.putExtras(bundle) intent.putExtras(bundle)