|
|
@ -46,6 +46,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun loadBookInfo(book: Book) { |
|
|
|
fun loadBookInfo(book: Book) { |
|
|
|
|
|
|
|
execute { |
|
|
|
isLoadingData.postValue(true) |
|
|
|
isLoadingData.postValue(true) |
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> |
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> |
|
|
|
WebBook(bookSource).getBookInfo(book, this) |
|
|
|
WebBook(bookSource).getBookInfo(book, this) |
|
|
@ -56,8 +57,10 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
} ?: toast(R.string.error_no_source) |
|
|
|
} ?: toast(R.string.error_no_source) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun loadChapter(book: Book) { |
|
|
|
fun loadChapter(book: Book) { |
|
|
|
|
|
|
|
execute { |
|
|
|
isLoadingData.postValue(true) |
|
|
|
isLoadingData.postValue(true) |
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> |
|
|
|
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> |
|
|
|
WebBook(bookSource).getChapterList(book, this) |
|
|
|
WebBook(bookSource).getChapterList(book, this) |
|
|
@ -76,6 +79,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
} ?: toast(R.string.error_no_source) |
|
|
|
} ?: toast(R.string.error_no_source) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun saveBook(success: (() -> Unit)?) { |
|
|
|
fun saveBook(success: (() -> Unit)?) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|