pull/32/head
kunfei 5 years ago
parent db62d46f13
commit 909c6028f2
  1. 27
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt
  2. 6
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt

@ -17,18 +17,23 @@ class ChangeSourceAdapter(context: Context) : SimpleRecyclerAdapter<SearchBook>(
override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList<Any>) {
holder.itemView.apply {
this.onClick {
callBack?.changeTo(item)
}
tv_origin.text = item.originName
tv_last.text = item.latestChapterTitle
callBack?.let {
if (it.curBookUrl() == item.bookUrl) {
iv_checked.visible()
} else {
iv_checked.invisible()
if (payloads.isEmpty()) {
this.onClick {
callBack?.changeTo(item)
}
} ?: iv_checked.invisible()
tv_origin.text = item.originName
tv_last.text = item.latestChapterTitle
callBack?.let {
if (it.curBookUrl() == item.bookUrl) {
iv_checked.visible()
} else {
iv_checked.invisible()
}
} ?: iv_checked.invisible()
} else {
tv_origin.text = item.originName
tv_last.text = item.latestChapterTitle
}
}
}

@ -36,8 +36,10 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
val books = searchBooks.toList()
val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList()))
withContext(Main) {
it.setItemsNoNotify(books)
diffResult.dispatchUpdatesTo(it)
synchronized(this) {
it.setItemsNoNotify(books)
diffResult.dispatchUpdatesTo(it)
}
}
}
}

Loading…
Cancel
Save