diff --git a/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt b/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt index 2ac1090f2..d5e92e236 100644 --- a/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt +++ b/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt @@ -9,6 +9,10 @@ import android.content.Context */ abstract class ItemViewDelegate(protected val context: Context, val layoutId: Int) { + /** + * 如果使用了事件回调,回调里不要直接使用item,会出现不更新的问题, + * 使用getItem(holder.layoutPosition)来获取item + */ abstract fun convert(holder: ItemViewHolder, item: ITEM, payloads: MutableList) } \ No newline at end of file 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 c65cfabf4..baf40e487 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 @@ -18,5 +18,9 @@ abstract class SimpleRecyclerAdapter(context: Context, private val layoutI }) } + /** + * 如果使用了事件回调,回调里不要直接使用item,会出现不更新的问题, + * 使用getItem(holder.layoutPosition)来获取item + */ abstract fun convert(holder: ItemViewHolder, item: ITEM, payloads: MutableList) } \ No newline at end of file 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 8633021f2..13b145a1e 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 @@ -27,7 +27,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio var author: String = "" private var task: Coroutine<*>? = null private var screenKey: String = "" - private val searchBooks = linkedSetOf() + private val searchBooks = hashSetOf() fun initData(arguments: Bundle?) { arguments?.let { bundle -> @@ -50,10 +50,8 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio } private fun upAdapter() { - execute { - val books = searchBooks.toList() - searchBooksLiveData.postValue(books.sortedBy { it.originOrder }) - } + val books = searchBooks.toList() + searchBooksLiveData.postValue(books.sortedBy { it.originOrder }) } private fun searchFinish(searchBook: SearchBook) {