From 909c6028f2f2ed3d83e49c44fc5a4d52fcf56bdf Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 20 Aug 2019 08:24:48 +0800 Subject: [PATCH] up --- .../ui/changesource/ChangeSourceAdapter.kt | 27 +++++++++++-------- .../ui/changesource/ChangeSourceViewModel.kt | 6 +++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt index 368527d4f..45e9da565 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt @@ -17,18 +17,23 @@ class ChangeSourceAdapter(context: Context) : SimpleRecyclerAdapter( override fun convert(holder: ItemViewHolder, item: SearchBook, payloads: MutableList) { 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 + } } } diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt index ac58feae8..b64d559f8 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt @@ -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) + } } } }