From 87f2aed7db4d3f1d1bb3282b34dcc447c4be4285 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 16 Dec 2020 08:08:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B9=A6=E6=BA=90=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E9=97=AA=E9=80=80bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/base/adapter/SimpleRecyclerAdapter.kt | 58 +------------------ .../app/ui/book/local/ImportBookAdapter.kt | 4 +- .../searchContent/SearchContentAdapter.kt | 4 +- .../source/debug/BookSourceDebugAdapter.kt | 4 +- .../rss/source/debug/RssSourceDebugAdapter.kt | 4 +- 5 files changed, 9 insertions(+), 65 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/adapter/SimpleRecyclerAdapter.kt b/app/src/main/java/io/legado/app/base/adapter/SimpleRecyclerAdapter.kt index d6a206656..f8c5e7e85 100644 --- a/app/src/main/java/io/legado/app/base/adapter/SimpleRecyclerAdapter.kt +++ b/app/src/main/java/io/legado/app/base/adapter/SimpleRecyclerAdapter.kt @@ -35,7 +35,7 @@ abstract class SimpleRecyclerAdapter(protected val conte object : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: ITEM, newItem: ITEM): Boolean { - return oldItem == newItem + return false } override fun areContentsTheSame(oldItem: ITEM, newItem: ITEM): Boolean { @@ -70,57 +70,6 @@ abstract class SimpleRecyclerAdapter(protected val conte } } - fun addItem(item: ITEM) { - synchronized(lock) { - val list = ArrayList(asyncListDiffer.currentList) - list.add(item) - asyncListDiffer.submitList(list) - } - } - - fun addItems(position: Int, newItems: List) { - synchronized(lock) { - val list = ArrayList(asyncListDiffer.currentList) - list.addAll(position, newItems) - asyncListDiffer.submitList(list) - } - } - - fun addItems(newItems: List) { - synchronized(lock) { - val list = ArrayList(asyncListDiffer.currentList) - list.addAll(newItems) - asyncListDiffer.submitList(list) - } - } - - fun removeItem(position: Int) { - synchronized(lock) { - val list = ArrayList(asyncListDiffer.currentList) - if (list.removeAt(position) != null) { - asyncListDiffer.submitList(list) - } - } - } - - fun removeItem(item: ITEM) { - synchronized(lock) { - val list = ArrayList(asyncListDiffer.currentList) - if (list.remove(item)) { - asyncListDiffer.submitList(list) - } - } - } - - fun removeItems(items: List) { - synchronized(lock) { - val list = ArrayList(asyncListDiffer.currentList) - if (list.removeAll(items)) { - asyncListDiffer.submitList(list) - } - } - } - fun swapItem(srcPosition: Int, targetPosition: Int) { synchronized(lock) { val list = ArrayList(getItems()) @@ -158,11 +107,6 @@ abstract class SimpleRecyclerAdapter(protected val conte } } - fun clearItems() = - synchronized(lock) { - asyncListDiffer.submitList(arrayListOf()) - } - fun isEmpty() = asyncListDiffer.currentList.isEmpty() fun isNotEmpty() = asyncListDiffer.currentList.isNotEmpty() diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt index 269125da4..417bf96aa 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt @@ -4,8 +4,8 @@ import android.content.Context import android.net.Uri import android.view.ViewGroup import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.AppConst import io.legado.app.databinding.ItemImportBookBinding import io.legado.app.utils.* @@ -13,7 +13,7 @@ import org.jetbrains.anko.sdk27.listeners.onClick class ImportBookAdapter(context: Context, val callBack: CallBack) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { var selectedUris = hashSetOf() var checkableCount = 0 private var bookFileNames = arrayListOf() diff --git a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentAdapter.kt b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentAdapter.kt index 6164c2938..b8bca39b7 100644 --- a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentAdapter.kt @@ -3,8 +3,8 @@ package io.legado.app.ui.book.searchContent import android.content.Context import android.view.ViewGroup import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.ItemSearchListBinding import io.legado.app.lib.theme.accentColor import io.legado.app.utils.getCompatColor @@ -12,7 +12,7 @@ import io.legado.app.utils.hexString import org.jetbrains.anko.sdk27.listeners.onClick class SearchContentAdapter(context: Context, val callback: Callback) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { val cacheFileNames = hashSetOf() val textColor = context.getCompatColor(R.color.primaryText).hexString.substring(2) diff --git a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugAdapter.kt index 31194f03e..c91c336eb 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugAdapter.kt @@ -4,12 +4,12 @@ import android.content.Context import android.view.View import android.view.ViewGroup import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.ItemLogBinding class BookSourceDebugAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemLogBinding { return ItemLogBinding.inflate(inflater, parent, false) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugAdapter.kt index 3371d2ef6..bb14033b7 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugAdapter.kt @@ -4,12 +4,12 @@ import android.content.Context import android.view.View import android.view.ViewGroup import io.legado.app.R +import io.legado.app.base.adapter.CommonRecyclerAdapter import io.legado.app.base.adapter.ItemViewHolder -import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.databinding.ItemLogBinding class RssSourceDebugAdapter(context: Context) : - SimpleRecyclerAdapter(context) { + CommonRecyclerAdapter(context) { override fun getViewBinding(parent: ViewGroup): ItemLogBinding { return ItemLogBinding.inflate(inflater, parent, false)