From c1a301523db89c9fbd6f922ac5bca4bc5570c1f4 Mon Sep 17 00:00:00 2001 From: cketti Date: Wed, 18 Dec 2019 15:17:45 +0100 Subject: [PATCH] Honor 'scrollToFolder' argument in 'ChooseFolderActivity' --- .../k9/ui/choosefolder/ChooseFolderActivity.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/choosefolder/ChooseFolderActivity.kt b/app/ui/src/main/java/com/fsck/k9/ui/choosefolder/ChooseFolderActivity.kt index 7ce17894d..f986b4974 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/choosefolder/ChooseFolderActivity.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/choosefolder/ChooseFolderActivity.kt @@ -33,6 +33,7 @@ class ChooseFolderActivity : K9Activity() { private val folderNameFormatter: FolderNameFormatter by inject() private val folderIconProvider by lazy { FolderIconProvider(theme) } + private lateinit var recyclerView: RecyclerView private lateinit var itemAdapter: ItemAdapter private lateinit var account: Account private var currentFolder: String? = null @@ -87,7 +88,7 @@ class ChooseFolderActivity : K9Activity() { } } - val recyclerView = findViewById(R.id.folderList) + recyclerView = findViewById(R.id.folderList) recyclerView.adapter = folderListAdapter } @@ -111,6 +112,19 @@ class ChooseFolderActivity : K9Activity() { .toList() itemAdapter.set(folderListItems) + + scrollToFolder(folderListItems) + } + + private fun scrollToFolder(folders: List) { + if (scrollToFolder == null) return + + val index = folders.indexOfFirst { it.serverId == scrollToFolder } + if (index != -1) { + recyclerView.scrollToPosition(index) + } + + scrollToFolder = null } override fun onCreateOptionsMenu(menu: Menu): Boolean {