mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
5cf73698a8
commit
325b500c85
@ -84,9 +84,6 @@ interface BookDao {
|
||||
@Query("SELECT * FROM books WHERE bookUrl = :bookUrl")
|
||||
fun getBook(bookUrl: String): Book?
|
||||
|
||||
@Query("SELECT * FROM books WHERE bookUrl = :bookUrl")
|
||||
fun getBookFlow(bookUrl: String): Flow<Book?>
|
||||
|
||||
@Query("SELECT * FROM books WHERE name = :name and author = :author")
|
||||
fun getBook(name: String, author: String): Book?
|
||||
|
||||
|
@ -19,7 +19,6 @@ import io.legado.app.model.webBook.WebBook
|
||||
import io.legado.app.service.BaseReadAloudService
|
||||
import io.legado.app.ui.book.read.page.entities.TextChapter
|
||||
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
||||
import io.legado.app.utils.LogUtils
|
||||
import io.legado.app.utils.stackTraceStr
|
||||
import io.legado.app.utils.toastOnUi
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -209,7 +208,6 @@ object ReadBook : CoroutineScope by MainScope() {
|
||||
prevTextChapter = curTextChapter
|
||||
curTextChapter = nextTextChapter
|
||||
nextTextChapter = null
|
||||
LogUtils.d("moveToNextChapter", "title ${curTextChapter?.chapter?.title}")
|
||||
if (curTextChapter == null) {
|
||||
AppLog.putDebug("moveToNextChapter-章节未加载,开始加载")
|
||||
callBack?.upContent()
|
||||
@ -240,7 +238,6 @@ object ReadBook : CoroutineScope by MainScope() {
|
||||
nextTextChapter = curTextChapter
|
||||
curTextChapter = prevTextChapter
|
||||
prevTextChapter = null
|
||||
LogUtils.d("moveToPrevChapter", "title ${curTextChapter?.chapter?.title}")
|
||||
if (curTextChapter == null) {
|
||||
callBack?.upContent()
|
||||
loadContent(durChapterIndex, upContent, resetPageOffset = false)
|
||||
@ -538,10 +535,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
||||
book.getUseReplaceRule()
|
||||
)
|
||||
}
|
||||
LogUtils.d("saveRead", "dur ${book.durChapterTitle}")
|
||||
}
|
||||
LogUtils.d("bookDao", "saveRead update latest ${book.latestChapterTitle}")
|
||||
LogUtils.d("bookDao", "saveRead update dur ${book.durChapterTitle}")
|
||||
appDb.bookDao.update(book)
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ import io.legado.app.ui.widget.dialog.VariableDialog
|
||||
import io.legado.app.ui.widget.dialog.WaitDialog
|
||||
import io.legado.app.utils.ColorUtils
|
||||
import io.legado.app.utils.GSON
|
||||
import io.legado.app.utils.LogUtils
|
||||
import io.legado.app.utils.StartActivityContract
|
||||
import io.legado.app.utils.dpToPx
|
||||
import io.legado.app.utils.gone
|
||||
@ -301,7 +300,6 @@ class BookInfoActivity :
|
||||
|
||||
private fun showBook(book: Book) = binding.run {
|
||||
showCover(book)
|
||||
LogUtils.d("showBook", "latest ${book.latestChapterTitle}")
|
||||
tvName.text = book.name
|
||||
tvAuthor.text = getString(R.string.author_show, book.getRealAuthor())
|
||||
tvOrigin.text = getString(R.string.origin_show, book.originName)
|
||||
@ -342,8 +340,6 @@ class BookInfoActivity :
|
||||
|
||||
else -> {
|
||||
book?.let {
|
||||
LogUtils.d("upLoading", "latest ${it.latestChapterTitle}")
|
||||
LogUtils.d("upLoading", "dur ${it.durChapterTitle}")
|
||||
binding.tvToc.text = getString(R.string.toc_s, it.durChapterTitle)
|
||||
binding.tvLasted.text = getString(R.string.lasted_show, it.latestChapterTitle)
|
||||
}
|
||||
|
@ -33,14 +33,12 @@ import io.legado.app.model.analyzeRule.AnalyzeUrl
|
||||
import io.legado.app.model.localBook.LocalBook
|
||||
import io.legado.app.model.webBook.WebBook
|
||||
import io.legado.app.utils.ArchiveUtils
|
||||
import io.legado.app.utils.LogUtils
|
||||
import io.legado.app.utils.UrlUtil
|
||||
import io.legado.app.utils.isContentScheme
|
||||
import io.legado.app.utils.postEvent
|
||||
import io.legado.app.utils.toastOnUi
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class BookInfoViewModel(application: Application) : BaseViewModel(application) {
|
||||
val bookData = MutableLiveData<Book>()
|
||||
@ -59,7 +57,6 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
|
||||
val bookUrl = intent.getStringExtra("bookUrl") ?: ""
|
||||
appDb.bookDao.getBook(name, author)?.let {
|
||||
inBookshelf = true
|
||||
LogUtils.d("BookInfoViewModel initData", "book ${it.name}")
|
||||
upBook(it)
|
||||
return@execute
|
||||
}
|
||||
@ -92,16 +89,6 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
|
||||
|
||||
private fun upBook(book: Book) {
|
||||
execute {
|
||||
launch {
|
||||
appDb.bookDao.getBookFlow(book.bookUrl).collect { book ->
|
||||
book?.let {
|
||||
LogUtils.d("getBookFlow", "name ${it.name}")
|
||||
LogUtils.d("getBookFlow", "use replace ${it.getUseReplaceRule()}")
|
||||
LogUtils.d("getBookFlow", "latest ${it.latestChapterTitle}")
|
||||
LogUtils.d("getBookFlow", "dur ${it.durChapterTitle}")
|
||||
}
|
||||
}
|
||||
}
|
||||
bookData.postValue(book)
|
||||
upCoverByRule(book)
|
||||
bookSource = if (book.isLocal) null else
|
||||
|
Loading…
Reference in New Issue
Block a user