|
|
|
@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData |
|
|
|
|
import io.legado.app.base.BaseViewModel |
|
|
|
|
import io.legado.app.data.appDb |
|
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
|
import io.legado.app.model.ReadBook |
|
|
|
|
import io.legado.app.model.localBook.LocalBook |
|
|
|
|
|
|
|
|
|
class TocViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
var bookUrl: String = "" |
|
|
|
@ -23,6 +25,25 @@ class TocViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun upBookTocRule(book: Book, finally: () -> Unit) { |
|
|
|
|
execute { |
|
|
|
|
execute { |
|
|
|
|
appDb.bookDao.update(book) |
|
|
|
|
LocalBook.getChapterList(book).let { |
|
|
|
|
book.latestChapterTime = System.currentTimeMillis() |
|
|
|
|
appDb.bookChapterDao.delByBook(book.bookUrl) |
|
|
|
|
appDb.bookChapterDao.insert(*it.toTypedArray()) |
|
|
|
|
appDb.bookDao.update(book) |
|
|
|
|
ReadBook.chapterSize = it.size |
|
|
|
|
ReadBook.upMsg(null) |
|
|
|
|
ReadBook.loadContent(resetPageOffset = true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}.onFinally { |
|
|
|
|
finally.invoke() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun reverseToc(success: (book: Book) -> Unit) { |
|
|
|
|
execute { |
|
|
|
|
bookData.value?.apply { |
|
|
|
|