From f566e2626147b23b2c07f124b86c7d1b1f63116b Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 12 Jul 2020 17:56:30 +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 --- .../main/bookshelf/books/BooksAdapterGrid.kt | 2 +- .../main/bookshelf/books/BooksAdapterList.kt | 2 +- .../main/bookshelf/books/BooksDiffCallBack.kt | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt index be725abe9..7967b3843 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterGrid.kt @@ -25,7 +25,7 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) : iv_cover.load(item.getDisplayCover(), item.name, item.author) upRefresh(this, item) } else { - bundle.keySet().map { + bundle.keySet().forEach { when (it) { "name" -> tv_name.text = item.name "cover" -> iv_cover.load(item.getDisplayCover(), item.name, item.author) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt index 7ed9a7d99..452ebe59e 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt @@ -28,7 +28,7 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) : iv_cover.load(item.getDisplayCover(), item.name, item.author) upRefresh(this, item) } else { - bundle.keySet().map { + bundle.keySet().forEach { when (it) { "name" -> tv_name.text = item.name "author" -> tv_author.text = item.author diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt index 0756daca5..f66c6480f 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksDiffCallBack.kt @@ -42,11 +42,20 @@ class BooksDiffCallBack(private val oldItems: List, private val newItems: val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] val bundle = bundleOf() - if (oldItem.name != newItem.name) bundle.putString("name", null) - if (oldItem.author != newItem.author) bundle.putString("author", null) - if (oldItem.durChapterTitle != newItem.durChapterTitle) bundle.putString("dur", null) - if (oldItem.latestChapterTitle != newItem.latestChapterTitle) bundle.putString("last", null) - if (oldItem.getDisplayCover() != newItem.getDisplayCover()) bundle.putString("cover", null) + if (oldItem.name != newItem.name) bundle.putString("name", newItem.name) + if (oldItem.author != newItem.author) bundle.putString("author", newItem.author) + if (oldItem.durChapterTitle != newItem.durChapterTitle) bundle.putString( + "dur", + newItem.durChapterTitle + ) + if (oldItem.latestChapterTitle != newItem.latestChapterTitle) bundle.putString( + "last", + newItem.latestChapterTitle + ) + if (oldItem.getDisplayCover() != newItem.getDisplayCover()) bundle.putString( + "cover", + newItem.getDisplayCover() + ) if (oldItem.lastCheckCount != newItem.lastCheckCount || oldItem.durChapterTime != newItem.durChapterTime || oldItem.getUnreadChapterNum() != newItem.getUnreadChapterNum()