pull/1732/head
kunfei 3 years ago
parent 4da2d09a1b
commit f5d3b27ae0
  1. 19
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt
  2. 19
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt

@ -23,6 +23,7 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.DialogBookChangeSourceBinding
import io.legado.app.help.config.AppConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.book.source.manage.BookSourceActivity
@ -54,6 +55,23 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
registerForActivityResult(StartActivityContract(BookSourceEditActivity::class.java)) {
viewModel.startSearch()
}
private val searchFinishCallback: (isEmpty: Boolean) -> Unit = {
if (it) {
val searchGroup = getPrefString("searchGroup")
if (!searchGroup.isNullOrEmpty()) {
launch {
alert("搜索结果为空") {
setMessage("${searchGroup}分组搜索结果为空,是否切换到全部分组")
cancelButton()
okButton {
putPrefString("searchGroup", "")
viewModel.startSearch()
}
}
}
}
}
}
override fun onStart() {
super.onStart()
@ -69,6 +87,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
initSearchView()
initBottomBar()
initLiveData()
viewModel.searchFinishCallback = searchFinishCallback
}
private fun showTitle() {

@ -25,6 +25,7 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.DialogChapterChangeSourceBinding
import io.legado.app.help.BookHelp
import io.legado.app.help.config.AppConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.elevation
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
@ -79,6 +80,23 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
dismissAllowingStateLoss()
}
private var searchBook: SearchBook? = null
private val searchFinishCallback: (isEmpty: Boolean) -> Unit = {
if (it) {
val searchGroup = getPrefString("searchGroup")
if (!searchGroup.isNullOrEmpty()) {
launch {
alert("搜索结果为空") {
setMessage("${searchGroup}分组搜索结果为空,是否切换到全部分组")
cancelButton()
okButton {
putPrefString("searchGroup", "")
viewModel.startSearch()
}
}
}
}
}
}
override fun onStart() {
super.onStart()
@ -96,6 +114,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
initSearchView()
initBottomBar()
initLiveData()
viewModel.searchFinishCallback = searchFinishCallback
}
private fun showTitle() {

Loading…
Cancel
Save