From df2898a4f26595648474d0f5d73cdf473fca5caa Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 19 Oct 2019 12:41:24 +0800 Subject: [PATCH] up --- .../legado/app/ui/book/search/SearchActivity.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index 3e35e1a02..91010e820 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -75,9 +75,9 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se else -> if (item.groupId == R.id.source_group) { item.isChecked = true if (item.title.toString() == getString(R.string.all_source)) { - putPrefString("sourceGroup", "") + putPrefString("searchGroup", "") } else { - putPrefString("sourceGroup", item.title.toString()) + putPrefString("searchGroup", item.title.toString()) } } } @@ -171,10 +171,17 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se } private fun upGroupMenu() { + val selectedGroup = getPrefString("searchGroup") ?: "" menu?.removeGroup(R.id.source_group) - menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source) + var item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source) + if (selectedGroup == "") { + item?.isChecked = true + } groups.map { - menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) + item = menu?.add(R.id.source_group, Menu.NONE, Menu.NONE, it) + if (it == selectedGroup) { + item?.isChecked = true + } } menu?.setGroupCheckable(R.id.source_group, true, true) }