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)