From 977b4121c9009be350c0aadc78fa46b57e95f69d Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 16 Dec 2019 17:05:04 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt | 2 +- .../legado/app/ui/book/source/manage/BookSourceViewModel.kt | 3 ++- .../java/io/legado/app/web/controller/SourceController.kt | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt index 9f13a4f39..f76ed3d13 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt @@ -75,7 +75,7 @@ interface BookSourceDao { fun update(vararg bookSource: BookSource) @Delete - fun delete(vararg bookSource: BookSource) + fun delete(bookSource: BookSource) @Query("delete from book_sources where bookSourceUrl = :key") fun delete(key: String) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 99e32c556..982476466 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -91,7 +91,8 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) App.db.bookSourceDao().getBookSource(it) }.let { val json = GSON.toJson(it) - val file = FileHelp.getFile(Backup.exportPath + File.separator + "exportBookSource.json") + val file = + FileHelp.getFile(Backup.exportPath + File.separator + "exportBookSource.json") file.writeText(json) } }.onSuccess { diff --git a/app/src/main/java/io/legado/app/web/controller/SourceController.kt b/app/src/main/java/io/legado/app/web/controller/SourceController.kt index 3711092fc..90c774370 100644 --- a/app/src/main/java/io/legado/app/web/controller/SourceController.kt +++ b/app/src/main/java/io/legado/app/web/controller/SourceController.kt @@ -71,7 +71,9 @@ class SourceController { fun deleteSources(postData: String?): ReturnData { kotlin.runCatching { GSON.fromJsonArray(postData)?.let { - App.db.bookSourceDao().delete(*it.toTypedArray()) + it.forEach { source -> + App.db.bookSourceDao().delete(source) + } } } return ReturnData().setData("已执行"/*okSources*/)