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