From 58e56af9f3f2153340bbdda11d9880f01a6e3228 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 8 Nov 2020 23:06:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/api/controller/BookshelfController.kt | 2 +- .../java/io/legado/app/ui/book/info/BookInfoActivity.kt | 2 +- .../java/io/legado/app/ui/book/info/BookInfoViewModel.kt | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/api/controller/BookshelfController.kt b/app/src/main/java/io/legado/app/api/controller/BookshelfController.kt index fcebe0721..2130340c3 100644 --- a/app/src/main/java/io/legado/app/api/controller/BookshelfController.kt +++ b/app/src/main/java/io/legado/app/api/controller/BookshelfController.kt @@ -78,7 +78,7 @@ object BookshelfController { val book = GSON.fromJsonObject(postData) val returnData = ReturnData() if (book != null) { - App.db.bookDao().update(book) + App.db.bookDao().insert(book) if (ReadBook.book?.bookUrl == book.bookUrl) { ReadBook.book = book ReadBook.durChapterIndex = book.durChapterIndex diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index fca961485..bfa3e963d 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -65,6 +65,7 @@ class BookInfoActivity : scroll_view.setBackgroundColor(backgroundColor) fl_action.setBackgroundColor(bottomBackground) tv_shelf.setTextColor(getPrimaryTextColor(ColorUtils.isColorLight(bottomBackground))) + tv_toc.text = getString(R.string.toc_s, getString(R.string.loading)) viewModel.bookData.observe(this, { showBook(it) }) viewModel.chapterListData.observe(this, { upLoading(false, it) }) viewModel.initData(intent) @@ -136,7 +137,6 @@ class BookInfoActivity : tv_author.text = getString(R.string.author_show, book.getRealAuthor()) tv_origin.text = getString(R.string.origin_show, book.originName) tv_lasted.text = getString(R.string.lasted_show, book.latestChapterTitle) - tv_toc.text = getString(R.string.toc_s, getString(R.string.loading)) tv_intro.text = book.getDisplayIntro() upTvBookshelf() val kinds = book.getKindList() diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index f04c7c34d..c0ff1d3cd 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -179,11 +179,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { book.durChapterPos = it.durChapterPos book.durChapterTitle = it.durChapterTitle } - if (App.db.bookDao().getBook(book.bookUrl) != null) { - App.db.bookDao().update(book) - } else { - App.db.bookDao().insert(book) - } + App.db.bookDao().insert(book) if (ReadBook.book?.name == book.name && ReadBook.book?.author == book.author) { ReadBook.book = book }