|
|
|
@ -13,6 +13,7 @@ import io.legado.app.help.BookHelp |
|
|
|
|
import io.legado.app.model.localBook.LocalBook |
|
|
|
|
import io.legado.app.model.webBook.WebBook |
|
|
|
|
import io.legado.app.service.help.ReadBook |
|
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
|
|
|
|
|
|
class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
@ -86,11 +87,11 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
} |
|
|
|
|
loadChapter(it, changeDruChapterIndex) |
|
|
|
|
}.onError { |
|
|
|
|
toastOnUi(R.string.error_get_book_info) |
|
|
|
|
context.toastOnUi(R.string.error_get_book_info) |
|
|
|
|
} |
|
|
|
|
} ?: let { |
|
|
|
|
chapterListData.postValue(emptyList()) |
|
|
|
|
toastOnUi(R.string.error_no_source) |
|
|
|
|
context.toastOnUi(R.string.error_no_source) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -122,15 +123,15 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
changeDruChapterIndex(it) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
toastOnUi(R.string.chapter_list_empty) |
|
|
|
|
context.toastOnUi(R.string.chapter_list_empty) |
|
|
|
|
} |
|
|
|
|
}.onError { |
|
|
|
|
chapterListData.postValue(emptyList()) |
|
|
|
|
toastOnUi(R.string.error_get_chapter_list) |
|
|
|
|
context.toastOnUi(R.string.error_get_chapter_list) |
|
|
|
|
} |
|
|
|
|
} ?: let { |
|
|
|
|
chapterListData.postValue(emptyList()) |
|
|
|
|
toastOnUi(R.string.error_no_source) |
|
|
|
|
context.toastOnUi(R.string.error_no_source) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}.onError { |
|
|
|
@ -260,9 +261,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
execute { |
|
|
|
|
BookHelp.clearCache(bookData.value!!) |
|
|
|
|
}.onSuccess { |
|
|
|
|
toastOnUi(R.string.clear_cache_success) |
|
|
|
|
context.toastOnUi(R.string.clear_cache_success) |
|
|
|
|
}.onError { |
|
|
|
|
toastOnUi(it.stackTraceToString()) |
|
|
|
|
context.toastOnUi(it.stackTraceToString()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|