|
|
@ -10,6 +10,7 @@ import io.legado.app.data.entities.Book |
|
|
|
class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
|
|
|
|
|
|
|
val bookData = MutableLiveData<Book>() |
|
|
|
val bookData = MutableLiveData<Book>() |
|
|
|
|
|
|
|
val isLoadingData = MutableLiveData<Boolean>() |
|
|
|
var inBookshelf = false |
|
|
|
var inBookshelf = false |
|
|
|
|
|
|
|
|
|
|
|
fun loadBook(intent: Intent) { |
|
|
|
fun loadBook(intent: Intent) { |
|
|
@ -20,8 +21,13 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
bookData.postValue(book) |
|
|
|
bookData.postValue(book) |
|
|
|
} |
|
|
|
} |
|
|
|
} ?: intent.getStringExtra("searchBookUrl")?.let { |
|
|
|
} ?: intent.getStringExtra("searchBookUrl")?.let { |
|
|
|
App.db.searchBookDao().getSearchBook(it)?.let { searchBook -> |
|
|
|
App.db.searchBookDao().getSearchBook(it)?.toBook()?.let { book -> |
|
|
|
bookData.postValue(searchBook.toBook()) |
|
|
|
bookData.postValue(book) |
|
|
|
|
|
|
|
if (book.tocUrl.isNullOrEmpty()) { |
|
|
|
|
|
|
|
loadBookInfo() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
loadChapter() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -31,4 +37,8 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun loadChapter() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |