From 7b6ac39e6d4d6eba93916ff2fa30199ad0057dde Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 9 Aug 2020 18:18:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=B7=BB=E5=8A=A0=E4=B9=A6?= =?UTF-8?q?=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/dao/BookmarkDao.kt | 4 ++-- app/src/main/java/io/legado/app/help/storage/Backup.kt | 1 + app/src/main/java/io/legado/app/help/storage/Restore.kt | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/BookmarkDao.kt b/app/src/main/java/io/legado/app/data/dao/BookmarkDao.kt index 14e852352..16fdff455 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookmarkDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookmarkDao.kt @@ -8,8 +8,8 @@ import io.legado.app.data.entities.Bookmark @Dao interface BookmarkDao { - @Query("select * from bookmarks") - fun all(): List + @get:Query("select * from bookmarks") + val all: List @Query("select * from bookmarks where bookUrl = :bookUrl or (bookName = :bookName and bookAuthor = :bookAuthor)") fun observeByBook( diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt index 5b1e88186..135330690 100644 --- a/app/src/main/java/io/legado/app/help/storage/Backup.kt +++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt @@ -42,6 +42,7 @@ object Backup { withContext(IO) { synchronized(this@Backup) { writeListToJson(App.db.bookDao().all, "bookshelf.json", backupPath) + writeListToJson(App.db.bookmarkDao().all, "bookmark.json", backupPath) writeListToJson(App.db.bookGroupDao().all, "bookGroup.json", backupPath) writeListToJson(App.db.bookSourceDao().all, "bookSource.json", backupPath) writeListToJson(App.db.rssSourceDao().all, "rssSource.json", backupPath) diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index bed5cd7ce..c2c527ddd 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -113,6 +113,9 @@ object Restore { fileToListT(path, "bookshelf.json")?.let { App.db.bookDao().insert(*it.toTypedArray()) } + fileToListT(path, "bookmark.json")?.let { + App.db.bookmarkDao().insert(*it.toTypedArray()) + } fileToListT(path, "bookGroup.json")?.let { App.db.bookGroupDao().insert(*it.toTypedArray()) }