|
|
@ -16,6 +16,7 @@ import io.legado.app.ui.book.read.page.provider.ChapterProvider |
|
|
|
import io.legado.app.ui.book.read.page.provider.ImageProvider |
|
|
|
import io.legado.app.ui.book.read.page.provider.ImageProvider |
|
|
|
import io.legado.app.utils.msg |
|
|
|
import io.legado.app.utils.msg |
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
|
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import kotlinx.coroutines.delay |
|
|
|
import kotlinx.coroutines.delay |
|
|
|
import splitties.init.appCtx |
|
|
|
import splitties.init.appCtx |
|
|
|
import kotlin.math.max |
|
|
|
import kotlin.math.max |
|
|
@ -270,7 +271,7 @@ object ReadBook { |
|
|
|
success?.invoke() |
|
|
|
success?.invoke() |
|
|
|
} |
|
|
|
} |
|
|
|
removeLoading(chapter.index) |
|
|
|
removeLoading(chapter.index) |
|
|
|
} ?: download(chapter, resetPageOffset = resetPageOffset) |
|
|
|
} ?: download(this, chapter, resetPageOffset = resetPageOffset) |
|
|
|
} ?: removeLoading(index) |
|
|
|
} ?: removeLoading(index) |
|
|
|
}.onError { |
|
|
|
}.onError { |
|
|
|
removeLoading(index) |
|
|
|
removeLoading(index) |
|
|
@ -288,7 +289,7 @@ object ReadBook { |
|
|
|
if (BookHelp.hasContent(book, chapter)) { |
|
|
|
if (BookHelp.hasContent(book, chapter)) { |
|
|
|
removeLoading(chapter.index) |
|
|
|
removeLoading(chapter.index) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
download(chapter, false) |
|
|
|
download(this, chapter, false) |
|
|
|
} |
|
|
|
} |
|
|
|
} ?: removeLoading(index) |
|
|
|
} ?: removeLoading(index) |
|
|
|
}.onError { |
|
|
|
}.onError { |
|
|
@ -299,6 +300,7 @@ object ReadBook { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun download( |
|
|
|
private fun download( |
|
|
|
|
|
|
|
scope: CoroutineScope, |
|
|
|
chapter: BookChapter, |
|
|
|
chapter: BookChapter, |
|
|
|
resetPageOffset: Boolean, |
|
|
|
resetPageOffset: Boolean, |
|
|
|
success: (() -> Unit)? = null |
|
|
|
success: (() -> Unit)? = null |
|
|
@ -306,7 +308,7 @@ object ReadBook { |
|
|
|
val book = book |
|
|
|
val book = book |
|
|
|
val webBook = webBook |
|
|
|
val webBook = webBook |
|
|
|
if (book != null && webBook != null) { |
|
|
|
if (book != null && webBook != null) { |
|
|
|
CacheBook.download(Coroutine.DEFAULT, webBook, book, chapter) |
|
|
|
CacheBook.download(scope, webBook, book, chapter) |
|
|
|
} else if (book != null) { |
|
|
|
} else if (book != null) { |
|
|
|
contentLoadFinish( |
|
|
|
contentLoadFinish( |
|
|
|
book, chapter, "没有书源", resetPageOffset = resetPageOffset |
|
|
|
book, chapter, "没有书源", resetPageOffset = resetPageOffset |
|
|
|