diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt index ffc51ce84..0da75c27f 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt @@ -20,22 +20,20 @@ class ChangeSourceAdapter( context: Context, val viewModel: ChangeSourceViewModel, val callBack: CallBack -) : - DiffRecyclerAdapter(context) { +) : DiffRecyclerAdapter(context) { - override val diffItemCallback: DiffUtil.ItemCallback - get() = object : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean { - return oldItem.bookUrl == newItem.bookUrl - } - - override fun areContentsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean { - return oldItem.originName == newItem.originName - && oldItem.getDisplayLastChapterTitle() == newItem.getDisplayLastChapterTitle() - } + override val diffItemCallback = object : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean { + return oldItem.bookUrl == newItem.bookUrl + } + override fun areContentsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean { + return oldItem.originName == newItem.originName + && oldItem.getDisplayLastChapterTitle() == newItem.getDisplayLastChapterTitle() } + } + override fun getViewBinding(parent: ViewGroup): ItemChangeSourceBinding { return ItemChangeSourceBinding.inflate(inflater, parent, false) } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BaseBooksAdapter.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BaseBooksAdapter.kt index e5a0428c5..6f3a1f9a9 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BaseBooksAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BaseBooksAdapter.kt @@ -11,18 +11,17 @@ abstract class BaseBooksAdapter( val callBack: CallBack ) : RecyclerView.Adapter() { - val diffItemCallback: DiffUtil.ItemCallback - get() = object : DiffUtil.ItemCallback() { + val diffItemCallback = object : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: Book, newItem: Book): Boolean { - return oldItem.name == newItem.name - && oldItem.author == newItem.author - } + override fun areItemsTheSame(oldItem: Book, newItem: Book): Boolean { + return oldItem.name == newItem.name + && oldItem.author == newItem.author + } - override fun areContentsTheSame(oldItem: Book, newItem: Book): Boolean { - return when { - oldItem.durChapterTime != newItem.durChapterTime -> false - oldItem.name != newItem.name -> false + override fun areContentsTheSame(oldItem: Book, newItem: Book): Boolean { + return when { + oldItem.durChapterTime != newItem.durChapterTime -> false + oldItem.name != newItem.name -> false oldItem.author != newItem.author -> false oldItem.durChapterTitle != newItem.durChapterTitle -> false oldItem.latestChapterTitle != newItem.latestChapterTitle -> false diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index 80ccfef1d..7c321c9ca 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -40,6 +40,7 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_explo private val searchView: SearchView by lazy { binding.titleBar.findViewById(R.id.search_view) } + private val diffItemCallBack = ExploreDiffItemCallBack() private val groups = linkedSetOf() private var exploreFlowJob: Job? = null private var groupsMenu: SubMenu? = null @@ -127,7 +128,7 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_explo } exploreFlow.collect { binding.tvEmptyMsg.isGone = it.isNotEmpty() || searchView.query.isNotEmpty() - adapter.setItems(it, ExploreDiffItemCallBack()) + adapter.setItems(it, diffItemCallBack) } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt index 42f7a4c67..34147a14c 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt @@ -36,18 +36,17 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) : return selection.sortedBy { it.customOrder } } - val diffItemCallback: DiffUtil.ItemCallback - get() = object : DiffUtil.ItemCallback() { + val diffItemCallback = object : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: RssSource, newItem: RssSource): Boolean { - return oldItem.sourceUrl == newItem.sourceUrl - } + override fun areItemsTheSame(oldItem: RssSource, newItem: RssSource): Boolean { + return oldItem.sourceUrl == newItem.sourceUrl + } - override fun areContentsTheSame(oldItem: RssSource, newItem: RssSource): Boolean { - return oldItem.sourceName == newItem.sourceName - && oldItem.sourceGroup == newItem.sourceGroup - && oldItem.enabled == newItem.enabled - } + override fun areContentsTheSame(oldItem: RssSource, newItem: RssSource): Boolean { + return oldItem.sourceName == newItem.sourceName + && oldItem.sourceGroup == newItem.sourceGroup + && oldItem.enabled == newItem.enabled + } override fun getChangePayload(oldItem: RssSource, newItem: RssSource): Any? { val payload = Bundle()