From 3bcf6a6c11d7f62138f1ab4d2c5371ed1ed8d2bf Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 29 Jul 2019 09:30:54 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/sourceedit/SourceEditViewModel.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt index bd8363ea5..e65cc5c94 100644 --- a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt +++ b/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)