From d31dbdb694f9655475fd919a601d81a6ed55b471 Mon Sep 17 00:00:00 2001 From: HapeLee <1321903405@qq.com> Date: Mon, 27 Oct 2025 01:06:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=8E=B0=E7=95=8C=E9=9D=A2=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kazusa/ui/main/explore/ExploreAdapter.kt | 33 +++++++++++-------- app/src/main/res/layout/item_find_book.xml | 4 ++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legato/kazusa/ui/main/explore/ExploreAdapter.kt b/app/src/main/java/io/legato/kazusa/ui/main/explore/ExploreAdapter.kt index 5f811c056..8c43b0398 100644 --- a/app/src/main/java/io/legato/kazusa/ui/main/explore/ExploreAdapter.kt +++ b/app/src/main/java/io/legato/kazusa/ui/main/explore/ExploreAdapter.kt @@ -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 diff --git a/app/src/main/res/layout/item_find_book.xml b/app/src/main/res/layout/item_find_book.xml index 2c8716c72..c13898671 100644 --- a/app/src/main/res/layout/item_find_book.xml +++ b/app/src/main/res/layout/item_find_book.xml @@ -37,7 +37,8 @@ style="@style/Widget.Material3Expressive.Button.IconButton.Tonal" android:layout_width="wrap_content" android:layout_height="wrap_content" - app:icon="@drawable/ic_arrow_right" + android:checkable="true" + app:icon="@drawable/m3_split_button_chevron_avd" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/> @@ -46,6 +47,7 @@ android:id="@+id/rotate_loading" android:layout_width="wrap_content" android:layout_height="wrap_content" + app:indicatorColor="?attr/colorSurface" app:indicatorSize="24dp" android:visibility="gone" app:layout_constraintTop_toTopOf="@id/iv_status"