发现界面优化

This commit is contained in:
HapeLee
2025-10-27 01:06:32 +08:00
parent d98abed00b
commit d31dbdb694
2 changed files with 22 additions and 15 deletions
@@ -65,8 +65,7 @@ class ExploreAdapter(
val isExpanded = (item.bookSourceUrl == expandedId)
if (isExpanded) {
ivStatus.icon = ContextCompat.getDrawable(context, R.drawable.ic_arrow_right)
ivStatus.rotation = 90f
ivStatus.isChecked = true
rotateLoading.visible()
if (scrollToId == item.bookSourceUrl) {
val pos = holder.bindingAdapterPosition
@@ -82,8 +81,7 @@ class ExploreAdapter(
rotateLoading.gone()
}
} else {
ivStatus.icon = ContextCompat.getDrawable(context, R.drawable.ic_arrow_right)
ivStatus.rotation = 0f
ivStatus.isChecked = false
recyclerFlexbox(flexbox)
flexbox.gone()
}
@@ -135,16 +133,10 @@ class ExploreAdapter(
override fun registerListener(holder: ItemViewHolder, binding: ItemFindBookBinding) {
binding.apply {
llTitle.setOnClickListener {
val item = getItem(holder.bindingAdapterPosition) ?: return@setOnClickListener
val oldId = expandedId
expandedId = if (expandedId == item.bookSourceUrl) null else item.bookSourceUrl
notifyItemChangedById(oldId)
notifyItemChangedById(expandedId)
if (expandedId != null) {
scrollToId = expandedId
callBack.scrollTo(holder.bindingAdapterPosition)
}
toggleExpandState(holder)
}
ivStatus.setOnClickListener {
toggleExpandState(holder)
}
llTitle.onLongClick {
showMenu(ivStatus, holder.bindingAdapterPosition)
@@ -152,6 +144,19 @@ class ExploreAdapter(
}
}
private fun toggleExpandState(holder: ItemViewHolder) {
val item = getItem(holder.bindingAdapterPosition) ?: return
val oldId = expandedId
expandedId = if (expandedId == item.bookSourceUrl) null else item.bookSourceUrl
notifyItemChangedById(oldId)
notifyItemChangedById(expandedId)
if (expandedId != null) {
scrollToId = expandedId
callBack.scrollTo(holder.bindingAdapterPosition)
}
}
fun compressExplore(): Boolean {
return if (expandedId == null) {
false