Skip to content

Commit 38b5098

Browse files
committed
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 <[email protected]>
1 parent 71e454d commit 38b5098

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ class ConversationsListActivity :
345345
showSearchOrToolbar()
346346
}
347347

348+
override fun onPause() {
349+
super.onPause()
350+
val firstVisible = layoutManager?.findFirstVisibleItemPosition() ?: 0
351+
val firstItem = adapter?.getItem(firstVisible)
352+
val firstTop = (firstItem as ConversationItem).mHolder?.itemView?.top
353+
val firstOffset = firstTop?.minus(CONVERSATION_ITEM_HEIGHT) ?: 0
354+
355+
appPreferences.setConversationListPositionAndOffset(firstVisible, firstOffset)
356+
}
357+
348358
// if edge to edge is used, add an empty item at the bottom of the list
349359
@Suppress("MagicNumber")
350360
private fun addEmptyItemForEdgeToEdgeIfNecessary() {
@@ -1881,12 +1891,6 @@ class ConversationsListActivity :
18811891
bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId)
18821892
selectedMessageId = null
18831893
}
1884-
val firstVisible = layoutManager?.findFirstVisibleItemPosition() ?: 0
1885-
val firstItem = adapter?.getItem(firstVisible)
1886-
val firstTop = (firstItem as ConversationItem).mHolder?.itemView?.top
1887-
val firstOffset = firstTop?.minus(CONVERSATION_ITEM_HEIGHT) ?: 0
1888-
1889-
appPreferences.setConversationListPositionAndOffset(firstVisible, firstOffset)
18901894

18911895
val intent = Intent(context, ChatActivity::class.java)
18921896
intent.putExtras(bundle)

0 commit comments

Comments
 (0)