pull/32/head
kunfei 5 years ago
parent 4a34a78816
commit b58d9de224
  1. 8
      app/src/main/java/io/legado/app/ui/main/explore/FindBookAdapter.kt
  2. 4
      app/src/main/java/io/legado/app/ui/main/explore/FindBookFragment.kt

@ -28,13 +28,11 @@ class FindBookAdapter(context: Context, private val scope: CoroutineScope, val c
tv_name.text = item.bookSourceName tv_name.text = item.bookSourceName
ll_title.onClick { ll_title.onClick {
val oldEx = exIndex val oldEx = exIndex
if (exIndex == holder.layoutPosition) { exIndex = if (exIndex == holder.layoutPosition) -1 else holder.layoutPosition
exIndex = -1 notifyItemChanged(oldEx, false)
} else { if (exIndex != -1) {
exIndex = holder.layoutPosition
notifyItemChanged(holder.layoutPosition, false) notifyItemChanged(holder.layoutPosition, false)
} }
notifyItemChanged(oldEx, false)
callBack.scrollTo(holder.layoutPosition) callBack.scrollTo(holder.layoutPosition)
} }
} }

@ -18,6 +18,7 @@ class FindBookFragment : BaseFragment(R.layout.fragment_find_book),
FindBookAdapter.CallBack { FindBookAdapter.CallBack {
private lateinit var adapter: FindBookAdapter private lateinit var adapter: FindBookAdapter
private lateinit var linearLayoutManager: LinearLayoutManager
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
setSupportToolbar(toolbar) setSupportToolbar(toolbar)
@ -31,7 +32,8 @@ class FindBookFragment : BaseFragment(R.layout.fragment_find_book),
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(rv_find) ATH.applyEdgeEffectColor(rv_find)
rv_find.layoutManager = LinearLayoutManager(context) linearLayoutManager = LinearLayoutManager(context)
rv_find.layoutManager = linearLayoutManager
adapter = FindBookAdapter(requireContext(), this, this) adapter = FindBookAdapter(requireContext(), this, this)
rv_find.adapter = adapter rv_find.adapter = adapter
} }

Loading…
Cancel
Save