pull/32/head
kunfei 5 years ago
parent 5886a3eaf1
commit 3bcf6a6c11
  1. 7
      app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt

@ -14,14 +14,15 @@ class SourceEditViewModel(application: Application) : BaseViewModel(application)
fun setBookSource(key: String) {
launch(IO) {
App.db.bookSourceDao().findByKey(key)?.let { sourceLiveData.postValue(it) }
App.db.bookSourceDao().findByKey(key)?.let {
sourceLiveData.postValue(it)
} ?: sourceLiveData.postValue(BookSource())
}
}
fun save(bookSource: BookSource, finally: (() -> Unit)? = null) {
launch(IO) {
val source = App.db.bookSourceDao().findByKey(bookSource.bookSourceUrl)
if (source == null) {
if (bookSource.customOrder == 0) {
bookSource.customOrder = App.db.bookSourceDao().allCount()
}
App.db.bookSourceDao().insert(bookSource)

Loading…
Cancel
Save