|
|
@ -70,31 +70,36 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private suspend fun setBook(book: Book) { |
|
|
|
private fun setBook(book: Book) { |
|
|
|
durChapterIndex = book.durChapterIndex |
|
|
|
execute { |
|
|
|
bookData.postValue(book) |
|
|
|
durChapterIndex = book.durChapterIndex |
|
|
|
if (book.customCoverUrl.isNullOrBlank()) { |
|
|
|
bookData.postValue(book) |
|
|
|
BookCover.searchCover(book)?.let { coverUrl -> |
|
|
|
upCoverByRule(book) |
|
|
|
book.customCoverUrl = coverUrl |
|
|
|
bookSource = if (book.isLocalBook()) null else |
|
|
|
bookData.postValue(book) |
|
|
|
appDb.bookSourceDao.getBookSource(book.origin) |
|
|
|
if (inBookshelf) { |
|
|
|
if (book.tocUrl.isEmpty()) { |
|
|
|
saveBook(book) |
|
|
|
loadBookInfo(book) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val chapterList = appDb.bookChapterDao.getChapterList(book.bookUrl) |
|
|
|
|
|
|
|
if (chapterList.isNotEmpty()) { |
|
|
|
|
|
|
|
chapterListData.postValue(chapterList) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
loadChapter(book) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
bookSource = if (book.isLocalBook()) { |
|
|
|
} |
|
|
|
null |
|
|
|
|
|
|
|
} else { |
|
|
|
private fun upCoverByRule(book: Book) { |
|
|
|
appDb.bookSourceDao.getBookSource(book.origin) |
|
|
|
execute { |
|
|
|
} |
|
|
|
if (book.customCoverUrl.isNullOrBlank()) { |
|
|
|
if (book.tocUrl.isEmpty()) { |
|
|
|
BookCover.searchCover(book)?.let { coverUrl -> |
|
|
|
loadBookInfo(book) |
|
|
|
book.customCoverUrl = coverUrl |
|
|
|
} else { |
|
|
|
bookData.postValue(book) |
|
|
|
val chapterList = appDb.bookChapterDao.getChapterList(book.bookUrl) |
|
|
|
if (inBookshelf) { |
|
|
|
if (chapterList.isNotEmpty()) { |
|
|
|
saveBook(book) |
|
|
|
chapterListData.postValue(chapterList) |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
loadChapter(book) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|