feat: 优化代码

pull/103/head
kunfei 5 years ago
parent a34f0df2d4
commit df5395f9a3
  1. 7
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt

@ -71,13 +71,14 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
override fun registerListener(holder: ItemViewHolder) { override fun registerListener(holder: ItemViewHolder) {
holder.itemView.apply { holder.itemView.apply {
ll_title.onClick { ll_title.onClick {
val position = holder.layoutPosition
val oldEx = exIndex val oldEx = exIndex
exIndex = if (exIndex == holder.layoutPosition) -1 else holder.layoutPosition exIndex = if (exIndex == position) -1 else position
notifyItemChanged(oldEx, false) notifyItemChanged(oldEx, false)
if (exIndex != -1) { if (exIndex != -1) {
notifyItemChanged(holder.layoutPosition, false) notifyItemChanged(position, false)
} }
callBack.scrollTo(holder.layoutPosition) callBack.scrollTo(position)
} }
ll_title.onLongClick { ll_title.onLongClick {
showMenu(ll_title, holder.layoutPosition) showMenu(ll_title, holder.layoutPosition)

Loading…
Cancel
Save