From 2960e693ce19827e7ab3e9528470d2e922dd3ed6 Mon Sep 17 00:00:00 2001 From: rapterjet2004 Date: Mon, 9 Jun 2025 11:46:00 -0500 Subject: [PATCH 1/4] Conversation List jumps to position of clicked conversation item when back pressed Signed-off-by: rapterjet2004 --- .../com/nextcloud/talk/chat/ChatActivity.kt | 8 +++++++- .../ConversationsListActivity.kt | 20 ++++++++++++++++++- .../nextcloud/talk/utils/bundle/BundleKeys.kt | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 4ad332bcd..f525c033e 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -195,6 +195,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_BREAKOUT_ROOM import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_MODERATOR import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_RECORDING_STATE import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_OFFSET import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_START_CALL_AFTER_ROOM_SWITCH import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SWITCH_TO_ROOM import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil @@ -369,6 +370,7 @@ class ChatActivity : var myFirstMessage: CharSequence? = null var checkingLobbyStatus: Boolean = false + private var listScrollOffset: Int = 0 private var conversationVoiceCallMenuItem: MenuItem? = null private var conversationVideoMenuItem: MenuItem? = null @@ -392,7 +394,10 @@ class ChatActivity : private val onBackPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { val intent = Intent(this@ChatActivity, ConversationsListActivity::class.java) - intent.putExtras(Bundle()) + val bundle = bundleOf() + bundle.putInt(KEY_SCROLL_OFFSET, listScrollOffset) + bundle.putString(KEY_ROOM_TOKEN, roomToken) + intent.putExtras(bundle) startActivity(intent) } } @@ -549,6 +554,7 @@ class ChatActivity : val extras: Bundle? = intent.extras roomToken = extras?.getString(KEY_ROOM_TOKEN).orEmpty() + listScrollOffset = extras?.getInt(KEY_SCROLL_OFFSET, 0) ?: 0 sharedText = extras?.getString(BundleKeys.KEY_SHARED_TEXT).orEmpty() diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index 07e70cca3..3e2d4177e 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -51,6 +51,7 @@ import androidx.core.view.isVisible import androidx.fragment.app.DialogFragment import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope +import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.work.Data import androidx.work.OneTimeWorkRequest @@ -141,6 +142,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FORWARD_MSG_FLAG import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FORWARD_MSG_TEXT import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_OFFSET import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_TO_NOTIFICATION_CATEGORY import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SHARED_TEXT import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil @@ -235,6 +237,8 @@ class ConversationsListActivity : private var conversationsListBottomDialog: ConversationsListBottomDialog? = null private var searchHelper: MessageSearchHelper? = null private var searchViewDisposable: Disposable? = null + private var roomTokenFromIntent: String? = null + private var scrollOffset: Int = 0 private var filterState = mutableMapOf( MENTION to false, @@ -307,6 +311,8 @@ class ConversationsListActivity : showNotificationWarning() showShareToScreen = hasActivityActionSendIntent() + roomTokenFromIntent = intent.extras?.getString(KEY_ROOM_TOKEN) + scrollOffset = intent.extras?.getInt(KEY_SCROLL_OFFSET, 0) ?: 0 if (!eventBus.isRegistered(this)) { eventBus.register(this) @@ -426,6 +432,17 @@ class ConversationsListActivity : .firstOrNull { ConversationUtils.isNoteToSelfConversation(it) } val isNoteToSelfAvailable = noteToSelf != null handleNoteToSelfShortcut(isNoteToSelfAvailable, noteToSelf?.token ?: "") + if (roomTokenFromIntent != null) { + val item = adapter?.currentItems?.first { + it is ConversationItem && it.model.token == roomTokenFromIntent + } + val pos = adapter?.currentItems?.indexOf(item) + pos?.let { + val layoutManager = binding.recyclerView.layoutManager as LinearLayoutManager + layoutManager.scrollToPosition(scrollOffset) + } + roomTokenFromIntent = null + } }.collect() } @@ -1879,7 +1896,8 @@ class ConversationsListActivity : bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId) selectedMessageId = null } - + val firstVisible = layoutManager?.findFirstVisibleItemPosition() ?: 0 + bundle.putInt(KEY_SCROLL_OFFSET, firstVisible) val intent = Intent(context, ChatActivity::class.java) intent.putExtras(bundle) startActivity(intent) diff --git a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt index cce659c74..ff65e3c7b 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt @@ -81,6 +81,7 @@ object BundleKeys { const val KEY_FIELD_MAP: String = "KEY_FIELD_MAP" const val KEY_CHAT_URL: String = "KEY_CHAT_URL" const val KEY_SCROLL_TO_NOTIFICATION_CATEGORY: String = "KEY_SCROLL_TO_NOTIFICATION_CATEGORY" + const val KEY_SCROLL_OFFSET: String = "KEY_SCROLL_OFFSET" const val KEY_FOCUS_INPUT: String = "KEY_FOCUS_INPUT" const val KEY_FROM_QR: String = "KEY_FROM_QR" } From 23e54350928cef1f46432e00d2adda0197a67417 Mon Sep 17 00:00:00 2001 From: rapterjet2004 Date: Thu, 3 Jul 2025 11:53:12 -0500 Subject: [PATCH 2/4] Updated scroll logic + removed old approach Signed-off-by: rapterjet2004 --- .../talk/adapters/items/ConversationItem.kt | 3 ++ .../com/nextcloud/talk/chat/ChatActivity.kt | 7 ----- .../ConversationsListActivity.kt | 28 ++++++------------- .../nextcloud/talk/utils/bundle/BundleKeys.kt | 1 - .../utils/preferences/AppPreferences.java | 6 ++++ .../utils/preferences/AppPreferencesImpl.kt | 23 +++++++++++++++ 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt index 3a189db33..ff6343534 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt @@ -59,6 +59,8 @@ class ConversationItem( IFilterable { private var header: GenericTextHeaderItem? = null private val chatMessage = model.lastMessage?.asModel() + var mHolder: ConversationItemViewHolder? = null + constructor( conversation: ConversationModel, @@ -97,6 +99,7 @@ class ConversationItem( position: Int, payloads: List ) { + mHolder = holder val appContext = sharedApplication!!.applicationContext holder.binding.dialogName.setTextColor( ResourcesCompat.getColor( diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index f525c033e..f01852456 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -195,7 +195,6 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_BREAKOUT_ROOM import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_MODERATOR import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_RECORDING_STATE import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN -import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_OFFSET import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_START_CALL_AFTER_ROOM_SWITCH import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SWITCH_TO_ROOM import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil @@ -370,7 +369,6 @@ class ChatActivity : var myFirstMessage: CharSequence? = null var checkingLobbyStatus: Boolean = false - private var listScrollOffset: Int = 0 private var conversationVoiceCallMenuItem: MenuItem? = null private var conversationVideoMenuItem: MenuItem? = null @@ -394,10 +392,6 @@ class ChatActivity : private val onBackPressedCallback = object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { val intent = Intent(this@ChatActivity, ConversationsListActivity::class.java) - val bundle = bundleOf() - bundle.putInt(KEY_SCROLL_OFFSET, listScrollOffset) - bundle.putString(KEY_ROOM_TOKEN, roomToken) - intent.putExtras(bundle) startActivity(intent) } } @@ -554,7 +548,6 @@ class ChatActivity : val extras: Bundle? = intent.extras roomToken = extras?.getString(KEY_ROOM_TOKEN).orEmpty() - listScrollOffset = extras?.getInt(KEY_SCROLL_OFFSET, 0) ?: 0 sharedText = extras?.getString(BundleKeys.KEY_SHARED_TEXT).orEmpty() diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index 3e2d4177e..3e61744cf 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -51,7 +51,6 @@ import androidx.core.view.isVisible import androidx.fragment.app.DialogFragment import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope -import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.work.Data import androidx.work.OneTimeWorkRequest @@ -142,7 +141,6 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FORWARD_MSG_FLAG import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FORWARD_MSG_TEXT import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN -import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_OFFSET import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_TO_NOTIFICATION_CATEGORY import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SHARED_TEXT import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil @@ -237,8 +235,6 @@ class ConversationsListActivity : private var conversationsListBottomDialog: ConversationsListBottomDialog? = null private var searchHelper: MessageSearchHelper? = null private var searchViewDisposable: Disposable? = null - private var roomTokenFromIntent: String? = null - private var scrollOffset: Int = 0 private var filterState = mutableMapOf( MENTION to false, @@ -311,8 +307,6 @@ class ConversationsListActivity : showNotificationWarning() showShareToScreen = hasActivityActionSendIntent() - roomTokenFromIntent = intent.extras?.getString(KEY_ROOM_TOKEN) - scrollOffset = intent.extras?.getInt(KEY_SCROLL_OFFSET, 0) ?: 0 if (!eventBus.isRegistered(this)) { eventBus.register(this) @@ -432,17 +426,9 @@ class ConversationsListActivity : .firstOrNull { ConversationUtils.isNoteToSelfConversation(it) } val isNoteToSelfAvailable = noteToSelf != null handleNoteToSelfShortcut(isNoteToSelfAvailable, noteToSelf?.token ?: "") - if (roomTokenFromIntent != null) { - val item = adapter?.currentItems?.first { - it is ConversationItem && it.model.token == roomTokenFromIntent - } - val pos = adapter?.currentItems?.indexOf(item) - pos?.let { - val layoutManager = binding.recyclerView.layoutManager as LinearLayoutManager - layoutManager.scrollToPosition(scrollOffset) - } - roomTokenFromIntent = null - } + + val pair = appPreferences.conversationListPositionAndOffset + layoutManager?.scrollToPositionWithOffset(pair.first, pair.second) }.collect() } @@ -1890,14 +1876,18 @@ class ConversationsListActivity : val bundle = Bundle() bundle.putString(KEY_ROOM_TOKEN, selectedConversation!!.token) - // bundle.putString(KEY_ROOM_ID, selectedConversation!!.roomId) bundle.putString(KEY_SHARED_TEXT, textToPaste) if (selectedMessageId != null) { bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId) selectedMessageId = null } val firstVisible = layoutManager?.findFirstVisibleItemPosition() ?: 0 - bundle.putInt(KEY_SCROLL_OFFSET, firstVisible) + val firstItem = adapter?.getItem(firstVisible) + val firstTop = (firstItem as ConversationItem).mHolder?.itemView?.top + val firstOffset = firstTop?.minus(44) ?: 0 + + appPreferences.setConversationListPositionAndOffset(firstVisible, firstOffset) + val intent = Intent(context, ChatActivity::class.java) intent.putExtras(bundle) startActivity(intent) diff --git a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt index ff65e3c7b..cce659c74 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt @@ -81,7 +81,6 @@ object BundleKeys { const val KEY_FIELD_MAP: String = "KEY_FIELD_MAP" const val KEY_CHAT_URL: String = "KEY_CHAT_URL" const val KEY_SCROLL_TO_NOTIFICATION_CATEGORY: String = "KEY_SCROLL_TO_NOTIFICATION_CATEGORY" - const val KEY_SCROLL_OFFSET: String = "KEY_SCROLL_OFFSET" const val KEY_FOCUS_INPUT: String = "KEY_FOCUS_INPUT" const val KEY_FROM_QR: String = "KEY_FROM_QR" } diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java index 60699b78c..9600cf3f7 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java @@ -13,6 +13,8 @@ import android.annotation.SuppressLint; import com.nextcloud.talk.ui.PlaybackSpeed; +import kotlin.Pair; + @SuppressLint("NonConstantResourceId") public interface AppPreferences { @@ -185,5 +187,9 @@ public interface AppPreferences { void setShowRegularNotificationWarning(boolean value); + void setConversationListPositionAndOffset(int position, int offset); + + Pair getConversationListPositionAndOffset(); + void clear(); } diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt index ec92560cf..1cdc75a43 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt @@ -412,6 +412,28 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } } + override fun setConversationListPositionAndOffset(position: Int, offset: Int) { + runBlocking { + async { + writeString(CONVERSATION_LIST_POSITION_OFFSET, "$position,$offset") + } + } + } + + override fun getConversationListPositionAndOffset(): Pair { + val pairString = runBlocking { + async { readString(CONVERSATION_LIST_POSITION_OFFSET).first() } + }.getCompleted() + + if (pairString.isEmpty()) return Pair(0,0) + + val pairArr = pairString.split(',') + val position = pairArr[0].toInt() + val offset = pairArr[1].toInt() + + return Pair(position, offset) + } + override fun setPhoneBookIntegrationLastRun(currentTimeMillis: Long) = runBlocking { async { @@ -626,6 +648,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { const val VOICE_MESSAGE_PLAYBACK_SPEEDS = "voice_message_playback_speeds" const val SHOW_REGULAR_NOTIFICATION_WARNING = "show_regular_notification_warning" const val LAST_NOTIFICATION_WARNING = "last_notification_warning" + const val CONVERSATION_LIST_POSITION_OFFSET = "CONVERSATION_LIST_POSITION_OFFSET" private fun String.convertStringToArray(): Array { var varString = this val floatList = mutableListOf() From 71e454d135ee7d5329a5ed96876ce0d1e568cbd2 Mon Sep 17 00:00:00 2001 From: rapterjet2004 Date: Tue, 15 Jul 2025 10:05:00 -0500 Subject: [PATCH 3/4] linter Signed-off-by: rapterjet2004 --- .../java/com/nextcloud/talk/adapters/items/ConversationItem.kt | 1 - .../talk/conversationlist/ConversationsListActivity.kt | 3 ++- .../com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt index ff6343534..a51124bc8 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt @@ -61,7 +61,6 @@ class ConversationItem( private val chatMessage = model.lastMessage?.asModel() var mHolder: ConversationItemViewHolder? = null - constructor( conversation: ConversationModel, user: User, diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index 3e61744cf..cae0a5c4a 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -1884,7 +1884,7 @@ class ConversationsListActivity : val firstVisible = layoutManager?.findFirstVisibleItemPosition() ?: 0 val firstItem = adapter?.getItem(firstVisible) val firstTop = (firstItem as ConversationItem).mHolder?.itemView?.top - val firstOffset = firstTop?.minus(44) ?: 0 + val firstOffset = firstTop?.minus(CONVERSATION_ITEM_HEIGHT) ?: 0 appPreferences.setConversationListPositionAndOffset(firstVisible, firstOffset) @@ -2229,5 +2229,6 @@ class ConversationsListActivity : private const val SIXTEEN_HOURS_IN_SECONDS: Long = 57600 const val LONG_1000: Long = 1000 private const val NOTE_TO_SELF_SHORTCUT_ID = "NOTE_TO_SELF_SHORTCUT_ID" + private const val CONVERSATION_ITEM_HEIGHT = 44 } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt index 1cdc75a43..18afbb6a1 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt @@ -425,7 +425,7 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { async { readString(CONVERSATION_LIST_POSITION_OFFSET).first() } }.getCompleted() - if (pairString.isEmpty()) return Pair(0,0) + if (pairString.isEmpty()) return Pair(0, 0) val pairArr = pairString.split(',') val position = pairArr[0].toInt() From 38b50984923fae619e54fc55fc0ef408028832c2 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Wed, 16 Jul 2025 15:58:44 +0200 Subject: [PATCH 4/4] 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 --- .../ConversationsListActivity.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index cae0a5c4a..5a4d30ad6 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -345,6 +345,16 @@ class ConversationsListActivity : 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 @Suppress("MagicNumber") private fun addEmptyItemForEdgeToEdgeIfNecessary() { @@ -1881,12 +1891,6 @@ class ConversationsListActivity : bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId) 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) intent.putExtras(bundle)