From b2d0bd5de27960ad2161ed48810e29620abae2d9 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 26 Feb 2020 22:12:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/search/DiffCallBack.kt | 10 ++++++---- .../io/legado/app/ui/book/search/SearchViewModel.kt | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt index 8db633cf8..5dc166987 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/DiffCallBack.kt @@ -16,10 +16,6 @@ class DiffCallBack(private val oldItems: List, private val newItems: } override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { - return true - } - - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { val oldItem = oldItems[oldItemPosition] val newItem = newItems[newItemPosition] if (oldItem.name != newItem.name) { @@ -28,6 +24,12 @@ class DiffCallBack(private val oldItems: List, private val newItems: if (oldItem.author != newItem.author) { return false } + return true + } + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + val oldItem = oldItems[oldItemPosition] + val newItem = newItems[newItemPosition] if (oldItem.origins?.size != newItem.origins?.size) { return false } diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index df104de88..1e780737e 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -130,9 +130,9 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { } } } else if (searchKey == item.author) { - for ((i, searchBook) in copyDataS.withIndex()) { + for ((index, searchBook) in copyDataS.withIndex()) { if (searchKey != searchBook.name && searchKey == searchBook.author) { - copyDataS.add(i, item) + copyDataS.add(index, item) break } }