pull/2143/head
kunfei 2 years ago
parent 5110ff8473
commit ee3777e511
  1. 5
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceViewModel.kt

@ -298,7 +298,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
waitDialog.setText(R.string.load_toc)
waitDialog.show()
val book = searchBook.toBook()
viewModel.getToc(book, {
val coroutine = viewModel.getToc(book, {
waitDialog.dismiss()
toastOnUi(it)
}) { toc, source ->
@ -306,6 +306,9 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
callBack?.changeTo(source, book, toc)
onSuccess?.invoke()
}
waitDialog.setOnCancelListener {
coroutine.cancel()
}
}
/**

@ -275,8 +275,8 @@ open class ChangeBookSourceViewModel(application: Application) : BaseViewModel(a
book: Book,
onError: (msg: String) -> Unit,
onSuccess: (toc: List<BookChapter>, source: BookSource) -> Unit
) {
execute {
): Coroutine<Pair<List<BookChapter>, BookSource>> {
return execute {
val toc = tocMap[book.bookUrl]
if (toc != null) {
val source = appDb.bookSourceDao.getBookSource(book.origin)

Loading…
Cancel
Save