pull/1753/head^2
kunfei 3 years ago
parent 2489c96b6b
commit ee689763a5
  1. 4
      app/src/main/java/io/legado/app/model/webBook/SearchModel.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt
  4. 13
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt

@ -8,7 +8,6 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.help.config.AppConfig
import io.legado.app.help.coroutine.CompositeCoroutine
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefString
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExecutorCoroutineDispatcher
import kotlinx.coroutines.asCoroutineDispatcher
@ -60,7 +59,7 @@ class SearchModel(private val scope: CoroutineScope) {
initSearchPool()
mSearchId = searchId
searchPage = 1
val searchGroup = appCtx.getPrefString("searchGroup") ?: ""
val searchGroup = AppConfig.searchGroup
bookSourceList.clear()
searchBooks.clear()
callBack?.onSearchSuccess(searchBooks)
@ -69,6 +68,7 @@ class SearchModel(private val scope: CoroutineScope) {
} else {
val sources = appDb.bookSourceDao.getEnabledByGroup(searchGroup)
if (sources.isEmpty()) {
AppConfig.searchGroup = ""
bookSourceList.addAll(appDb.bookSourceDao.allEnabled)
} else {
bookSourceList.addAll(sources)

@ -298,7 +298,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
*/
private fun upGroupMenu() {
val menu: Menu = binding.toolBar.menu
val selectedGroup = getPrefString("searchGroup")
val selectedGroup = AppConfig.searchGroup
menu.removeGroup(R.id.source_group)
val allItem = menu.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source)
var hasSelectedGroup = false

@ -331,7 +331,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
*/
private fun upGroupMenu() {
val menu: Menu = binding.toolBar.menu
val selectedGroup = getPrefString("searchGroup")
val selectedGroup = AppConfig.searchGroup
menu.removeGroup(R.id.source_group)
val allItem = menu.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source)
var hasSelectedGroup = false

@ -22,6 +22,7 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.SearchKeyword
import io.legado.app.databinding.ActivityBookSearchBinding
import io.legado.app.help.config.AppConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.*
import io.legado.app.ui.book.info.BookInfoActivity
@ -66,14 +67,14 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
private var groups = linkedSetOf<String>()
private val searchFinishCallback: (isEmpty: Boolean) -> Unit = {
if (it) {
val searchGroup = getPrefString("searchGroup")
if (!searchGroup.isNullOrEmpty()) {
val searchGroup = AppConfig.searchGroup
if (searchGroup.isNotEmpty()) {
launch {
alert("搜索结果为空") {
setMessage("${searchGroup}分组搜索结果为空,是否切换到全部分组")
cancelButton()
okButton {
putPrefString("searchGroup", "")
AppConfig.searchGroup = ""
viewModel.searchKey = ""
viewModel.search(searchView.query.toString())
}
@ -123,9 +124,9 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
else -> if (item.groupId == R.id.source_group) {
item.isChecked = true
if (item.title.toString() == getString(R.string.all_source)) {
putPrefString("searchGroup", "")
AppConfig.searchGroup = ""
} else {
putPrefString("searchGroup", item.title.toString())
AppConfig.searchGroup = item.title.toString()
}
searchView.query?.toString()?.trim()?.let {
searchView.setQuery(it, true)
@ -280,7 +281,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
* 更新分组菜单
*/
private fun upGroupMenu() = menu?.let { menu ->
val selectedGroup = getPrefString("searchGroup")
val selectedGroup = AppConfig.searchGroup
menu.removeGroup(R.id.source_group)
val allItem = menu.add(R.id.source_group, Menu.NONE, Menu.NONE, R.string.all_source)
var hasSelectedGroup = false

Loading…
Cancel
Save