优化
This commit is contained in:
@@ -549,6 +549,10 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
mCallback?.showLoading()
|
||||
}
|
||||
|
||||
fun loadFail(msg: String, retry: Boolean = true) {
|
||||
mCallback?.loadFail(msg, retry)
|
||||
}
|
||||
|
||||
fun onChapterListUpdated(newBook: Book) {
|
||||
if (newBook.isSameNameAuthor(book)) {
|
||||
book = newBook
|
||||
@@ -622,7 +626,7 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
|
||||
interface Callback {
|
||||
fun upContent()
|
||||
fun loadFail(msg: String)
|
||||
fun loadFail(msg: String, retry: Boolean = true)
|
||||
fun sureNewProgress(progress: BookProgress)
|
||||
fun showLoading()
|
||||
fun startLoad()
|
||||
|
||||
@@ -379,11 +379,12 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
mScrollTimer.isEnabled = false
|
||||
}
|
||||
|
||||
override fun loadFail(msg: String) {
|
||||
override fun loadFail(msg: String, retry: Boolean) {
|
||||
lifecycleScope.launch {
|
||||
if (loadingViewVisible) {
|
||||
binding.llLoading.isGone = true
|
||||
binding.llRetry.isVisible = true
|
||||
binding.tvRetry.isVisible = retry
|
||||
binding.tvMsg.text = msg
|
||||
} else {
|
||||
loadMoreView.error(null, "加载失败,点击重试")
|
||||
|
||||
@@ -54,7 +54,10 @@ class ReadMangaViewModel(application: Application) : BaseViewModel(application)
|
||||
} ?: ReadManga.book
|
||||
when {
|
||||
book != null -> initManga(book)
|
||||
else -> context.getString(R.string.no_book)//没有找到书
|
||||
else -> {
|
||||
ReadManga.loadFail(context.getString(R.string.no_book), false)
|
||||
AppLog.put("未找到漫画书籍\nbookUrl:$bookUrl")
|
||||
}
|
||||
}
|
||||
}.onSuccess {
|
||||
success?.invoke()
|
||||
|
||||
@@ -92,7 +92,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
||||
} ?: ReadBook.book
|
||||
when {
|
||||
book != null -> initBook(book)
|
||||
else -> ReadBook.upMsg(context.getString(R.string.no_book))
|
||||
else -> {
|
||||
ReadBook.upMsg(context.getString(R.string.no_book))
|
||||
AppLog.put("未找到书籍\nbookUrl:$bookUrl")
|
||||
}
|
||||
}
|
||||
}.onSuccess {
|
||||
success?.invoke()
|
||||
|
||||
Reference in New Issue
Block a user