|
|
@ -9,6 +9,7 @@ import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.SearchBook |
|
|
|
import io.legado.app.data.entities.SearchBook |
|
|
|
import io.legado.app.model.WebBook |
|
|
|
import io.legado.app.model.WebBook |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
|
|
|
import org.jetbrains.anko.debug |
|
|
|
|
|
|
|
|
|
|
|
class ChangeSourceViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
class ChangeSourceViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
var curBookUrl = "" |
|
|
|
var curBookUrl = "" |
|
|
@ -56,9 +57,9 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio |
|
|
|
.onSuccess { |
|
|
|
.onSuccess { |
|
|
|
it?.let { loadChapter(it) } |
|
|
|
it?.let { loadChapter(it) } |
|
|
|
}.onError { |
|
|
|
}.onError { |
|
|
|
toast(R.string.error_get_book_info) |
|
|
|
debug { context.getString(R.string.error_get_book_info) } |
|
|
|
} |
|
|
|
} |
|
|
|
} ?: toast(R.string.error_no_source) |
|
|
|
} ?: debug { context.getString(R.string.error_no_source) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun loadChapter(book: Book) { |
|
|
|
private fun loadChapter(book: Book) { |
|
|
@ -72,9 +73,9 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio |
|
|
|
App.db.searchBookDao().insert(searchBook) |
|
|
|
App.db.searchBookDao().insert(searchBook) |
|
|
|
} |
|
|
|
} |
|
|
|
}.onError { |
|
|
|
}.onError { |
|
|
|
toast(R.string.error_get_chapter_list) |
|
|
|
debug { context.getString(R.string.error_get_chapter_list) } |
|
|
|
} |
|
|
|
} |
|
|
|
} ?: toast(R.string.error_no_source) |
|
|
|
} ?: debug { R.string.error_no_source } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun screen(key: String?) { |
|
|
|
fun screen(key: String?) { |
|
|
|