pull/1440/head
gedoor 3 years ago
parent 2e19bf6978
commit fa98d8c5bb
  1. 6
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceAdapter.kt
  2. 3
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BaseBooksAdapter.kt
  3. 3
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  4. 3
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt

@ -20,11 +20,9 @@ class ChangeSourceAdapter(
context: Context, context: Context,
val viewModel: ChangeSourceViewModel, val viewModel: ChangeSourceViewModel,
val callBack: CallBack val callBack: CallBack
) : ) : DiffRecyclerAdapter<SearchBook, ItemChangeSourceBinding>(context) {
DiffRecyclerAdapter<SearchBook, ItemChangeSourceBinding>(context) {
override val diffItemCallback: DiffUtil.ItemCallback<SearchBook> override val diffItemCallback = object : DiffUtil.ItemCallback<SearchBook>() {
get() = object : DiffUtil.ItemCallback<SearchBook>() {
override fun areItemsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean { override fun areItemsTheSame(oldItem: SearchBook, newItem: SearchBook): Boolean {
return oldItem.bookUrl == newItem.bookUrl return oldItem.bookUrl == newItem.bookUrl
} }

@ -11,8 +11,7 @@ abstract class BaseBooksAdapter<VH : RecyclerView.ViewHolder>(
val callBack: CallBack val callBack: CallBack
) : RecyclerView.Adapter<VH>() { ) : RecyclerView.Adapter<VH>() {
val diffItemCallback: DiffUtil.ItemCallback<Book> val diffItemCallback = object : DiffUtil.ItemCallback<Book>() {
get() = object : DiffUtil.ItemCallback<Book>() {
override fun areItemsTheSame(oldItem: Book, newItem: Book): Boolean { override fun areItemsTheSame(oldItem: Book, newItem: Book): Boolean {
return oldItem.name == newItem.name return oldItem.name == newItem.name

@ -40,6 +40,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
private val searchView: SearchView by lazy { private val searchView: SearchView by lazy {
binding.titleBar.findViewById(R.id.search_view) binding.titleBar.findViewById(R.id.search_view)
} }
private val diffItemCallBack = ExploreDiffItemCallBack()
private val groups = linkedSetOf<String>() private val groups = linkedSetOf<String>()
private var exploreFlowJob: Job? = null private var exploreFlowJob: Job? = null
private var groupsMenu: SubMenu? = null private var groupsMenu: SubMenu? = null
@ -127,7 +128,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
} }
exploreFlow.collect { exploreFlow.collect {
binding.tvEmptyMsg.isGone = it.isNotEmpty() || searchView.query.isNotEmpty() binding.tvEmptyMsg.isGone = it.isNotEmpty() || searchView.query.isNotEmpty()
adapter.setItems(it, ExploreDiffItemCallBack()) adapter.setItems(it, diffItemCallBack)
} }
} }
} }

@ -36,8 +36,7 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
return selection.sortedBy { it.customOrder } return selection.sortedBy { it.customOrder }
} }
val diffItemCallback: DiffUtil.ItemCallback<RssSource> val diffItemCallback = object : DiffUtil.ItemCallback<RssSource>() {
get() = object : DiffUtil.ItemCallback<RssSource>() {
override fun areItemsTheSame(oldItem: RssSource, newItem: RssSource): Boolean { override fun areItemsTheSame(oldItem: RssSource, newItem: RssSource): Boolean {
return oldItem.sourceUrl == newItem.sourceUrl return oldItem.sourceUrl == newItem.sourceUrl

Loading…
Cancel
Save