From e58cb1f0cc2c9490456ad8c2a37b4ad8a9f4c0b5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 16 Dec 2020 13:49:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/base/adapter/DiffRecyclerAdapter.kt | 13 +++++++++++-- .../app/ui/book/source/manage/BookSourceActivity.kt | 3 +-- .../app/ui/book/source/manage/BookSourceAdapter.kt | 7 +++++++ .../app/ui/rss/source/manage/RssSourceActivity.kt | 1 - .../app/ui/rss/source/manage/RssSourceAdapter.kt | 7 +++++++ 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/adapter/DiffRecyclerAdapter.kt b/app/src/main/java/io/legado/app/base/adapter/DiffRecyclerAdapter.kt index ea96c3b61..aa4a3a4bd 100644 --- a/app/src/main/java/io/legado/app/base/adapter/DiffRecyclerAdapter.kt +++ b/app/src/main/java/io/legado/app/base/adapter/DiffRecyclerAdapter.kt @@ -16,12 +16,14 @@ import kotlin.collections.ArrayList */ @Suppress("unused") abstract class DiffRecyclerAdapter(protected val context: Context) : - RecyclerView.Adapter() { + RecyclerView.Adapter(), AsyncListDiffer.ListListener { val inflater: LayoutInflater = LayoutInflater.from(context) private val asyncListDiffer: AsyncListDiffer by lazy { - AsyncListDiffer(this, diffItemCallback) + AsyncListDiffer(this, diffItemCallback).apply { + addListListener(this@DiffRecyclerAdapter) + } } private val lock = Object() @@ -144,6 +146,13 @@ abstract class DiffRecyclerAdapter(protected val context final override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {} + override fun onCurrentListChanged( + previousList: MutableList, + currentList: MutableList + ) { + + } + @Suppress("UNCHECKED_CAST") final override fun onBindViewHolder( holder: ItemViewHolder, diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 2296040d7..c14809aaf 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -152,7 +152,7 @@ class BookSourceActivity : VMBaseActivity data.reversed() } adapter.setItems(sourceList) - upCountView() }) } diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index 41e5a1819..ef1a7f2c7 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -147,6 +147,13 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : } } + override fun onCurrentListChanged( + previousList: MutableList, + currentList: MutableList + ) { + callBack.upCountView() + } + private fun showMenu(view: View, position: Int) { val source = getItem(position) ?: return val popupMenu = PopupMenu(context, view) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index dd11955de..4649cf826 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -209,7 +209,6 @@ class RssSourceActivity : VMBaseActivity, + currentList: MutableList + ) { + callBack.upCountView() + } + fun selectAll() { getItems().forEach { selected.add(it)