diff --git a/app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt b/app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt index 2b04d0d5b..06bc23c1b 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt @@ -28,13 +28,11 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c tv_name.text = item.bookSourceName ll_title.onClick { val oldEx = exIndex - if (exIndex == holder.layoutPosition) { - exIndex = -1 - } else { - exIndex = holder.layoutPosition + exIndex = if (exIndex == holder.layoutPosition) -1 else holder.layoutPosition + notifyItemChanged(oldEx, false) + if (exIndex != -1) { notifyItemChanged(holder.layoutPosition, false) } - notifyItemChanged(oldEx, false) callBack.scrollTo(holder.layoutPosition) } } diff --git a/app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt index 76ed36885..4268bb719 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt @@ -18,6 +18,7 @@ class FindBookFragment : BaseFragment(R.layout.fragment_find_book), FindBookAdapter.CallBack { private lateinit var adapter: FindBookAdapter + private lateinit var linearLayoutManager: LinearLayoutManager override fun onViewCreated(view: View, savedInstanceState: Bundle?) { setSupportToolbar(toolbar) @@ -31,7 +32,8 @@ class FindBookFragment : BaseFragment(R.layout.fragment_find_book), private fun initRecyclerView() { ATH.applyEdgeEffectColor(rv_find) - rv_find.layoutManager = LinearLayoutManager(context) + linearLayoutManager = LinearLayoutManager(context) + rv_find.layoutManager = linearLayoutManager adapter = FindBookAdapter(requireContext(), this, this) rv_find.adapter = adapter }