feat: 国际出港/进港子列表展开按钮始终显示并增加空状态占位
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,8 @@ import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.ItemIntExpArriveBinding
|
||||
import com.lukouguoji.module_base.adapter.setCommonAdapter
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.bean.GjcMaWb
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
|
||||
@@ -24,20 +24,17 @@ class IntExpArriveViewHolder(view: View) :
|
||||
|
||||
// 添加图标点击事件 - 切换选择状态
|
||||
binding.ivIcon.setOnClickListener {
|
||||
// 反转checked状态
|
||||
bean.checked.set(!bean.checked.get())
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).tryEmit("check_changed")
|
||||
|
||||
// 立即更新UI(图片自动切换)
|
||||
binding.executePendingBindings()
|
||||
}
|
||||
|
||||
// ========== 展开按钮点击事件 ==========
|
||||
// 展开按钮点击事件
|
||||
binding.ivShow.setOnClickListener {
|
||||
bean.showMore.set(!bean.showMore.get())
|
||||
}
|
||||
|
||||
// ========== 初始化子列表 RecyclerView ==========
|
||||
// 初始化子列表 RecyclerView
|
||||
setCommonAdapter(
|
||||
binding.rvSub,
|
||||
IntExpArriveSubViewHolder::class.java,
|
||||
@@ -45,6 +42,22 @@ class IntExpArriveViewHolder(view: View) :
|
||||
)
|
||||
|
||||
// 刷新子列表数据
|
||||
binding.rvSub.refresh(bean.haWbList ?: emptyList())
|
||||
val subList = bean.haWbList ?: emptyList()
|
||||
binding.rvSub.refresh(subList)
|
||||
updateSubListVisibility(subList.isNotEmpty())
|
||||
}
|
||||
|
||||
private fun updateSubListVisibility(hasData: Boolean) {
|
||||
if (hasData) {
|
||||
binding.llHeader.visibility = View.VISIBLE
|
||||
binding.dividerHeader.visibility = View.VISIBLE
|
||||
binding.rvSub.visibility = View.VISIBLE
|
||||
binding.tvEmpty.visibility = View.GONE
|
||||
} else {
|
||||
binding.llHeader.visibility = View.GONE
|
||||
binding.dividerHeader.visibility = View.GONE
|
||||
binding.rvSub.visibility = View.GONE
|
||||
binding.tvEmpty.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,20 +24,17 @@ class IntExpTallyViewHolder(view: View) :
|
||||
|
||||
// 图标点击切换选择状态(主单和分单独立,互不干扰)
|
||||
binding.ivIcon.setOnClickListener {
|
||||
// 只切换主单自己的选择状态,不同步到分单
|
||||
bean.checked.set(!bean.checked.get())
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).tryEmit("check_changed")
|
||||
|
||||
// 刷新UI
|
||||
binding.executePendingBindings()
|
||||
}
|
||||
|
||||
// ========== 新增:展开按钮点击事件 ==========
|
||||
// 展开按钮点击事件
|
||||
binding.ivShow.setOnClickListener {
|
||||
bean.showMore.set(!bean.showMore.get())
|
||||
}
|
||||
|
||||
// ========== 新增:初始化子列表 RecyclerView ==========
|
||||
// 初始化子列表 RecyclerView
|
||||
setCommonAdapter(
|
||||
binding.rvSub,
|
||||
IntExpTallySubViewHolder::class.java,
|
||||
@@ -45,6 +42,22 @@ class IntExpTallyViewHolder(view: View) :
|
||||
)
|
||||
|
||||
// 刷新子列表数据
|
||||
binding.rvSub.refresh(bean.haWbList ?: emptyList())
|
||||
val subList = bean.haWbList ?: emptyList()
|
||||
binding.rvSub.refresh(subList)
|
||||
updateSubListVisibility(subList.isNotEmpty())
|
||||
}
|
||||
|
||||
private fun updateSubListVisibility(hasData: Boolean) {
|
||||
if (hasData) {
|
||||
binding.llHeader.visibility = View.VISIBLE
|
||||
binding.dividerHeader.visibility = View.VISIBLE
|
||||
binding.rvSub.visibility = View.VISIBLE
|
||||
binding.tvEmpty.visibility = View.GONE
|
||||
} else {
|
||||
binding.llHeader.visibility = View.GONE
|
||||
binding.dividerHeader.visibility = View.GONE
|
||||
binding.rvSub.visibility = View.GONE
|
||||
binding.tvEmpty.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,12 +95,8 @@ class IntExpArriveViewModel : BasePageViewModel() {
|
||||
val shouldExpand = !isAllExpanded.value!!
|
||||
isAllExpanded.value = shouldExpand
|
||||
|
||||
// 更新所有列表项的 showMore 状态
|
||||
list.forEach { bean ->
|
||||
// 只有当有子列表时才设置展开状态
|
||||
if (!bean.haWbList.isNullOrEmpty()) {
|
||||
bean.showMore.set(shouldExpand)
|
||||
}
|
||||
bean.showMore.set(shouldExpand)
|
||||
}
|
||||
|
||||
// 刷新列表UI
|
||||
|
||||
@@ -96,12 +96,8 @@ class IntExpTallyViewModel : BasePageViewModel() {
|
||||
val shouldExpand = !isAllExpanded.value!!
|
||||
isAllExpanded.value = shouldExpand
|
||||
|
||||
// 更新所有列表项的 showMore 状态
|
||||
list.forEach { bean ->
|
||||
// 只有当有子列表时才设置展开状态
|
||||
if (!bean.haWbList.isNullOrEmpty()) {
|
||||
bean.showMore.set(shouldExpand)
|
||||
}
|
||||
bean.showMore.set(shouldExpand)
|
||||
}
|
||||
|
||||
// 刷新列表UI
|
||||
|
||||
@@ -336,7 +336,6 @@
|
||||
<!-- 展开按钮 -->
|
||||
<ImageView
|
||||
android:id="@+id/iv_show"
|
||||
visible="@{bean.haWbList != null && !bean.haWbList.empty}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:paddingVertical="2.5dp"
|
||||
@@ -356,8 +355,21 @@
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<!-- 暂无数据提示 -->
|
||||
<TextView
|
||||
android:id="@+id/tv_empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="15dp"
|
||||
android:text="暂无分单数据"
|
||||
android:textColor="@color/text_gray"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 表头 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="10dp"
|
||||
@@ -467,6 +479,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/sub_list_divider" />
|
||||
|
||||
@@ -76,7 +76,6 @@
|
||||
<!-- 展开/折叠按钮 -->
|
||||
<ImageView
|
||||
android:id="@+id/iv_show"
|
||||
visible="@{bean.haWbList != null && !bean.haWbList.empty}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:paddingVertical="2.5dp"
|
||||
@@ -86,8 +85,19 @@
|
||||
</LinearLayout>
|
||||
<!-- 子订单列表容器(在白色卡片外面) -->
|
||||
<LinearLayout visible="@{bean.showMore}" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:background="#e3f6e0" android:orientation="vertical" android:visibility="gone">
|
||||
<!-- 暂无数据提示 -->
|
||||
<TextView
|
||||
android:id="@+id/tv_empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingVertical="15dp"
|
||||
android:text="暂无分单数据"
|
||||
android:textColor="@color/text_gray"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone" />
|
||||
<!-- 表头 -->
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginVertical="10dp" android:paddingHorizontal="10dp" android:orientation="horizontal">
|
||||
<LinearLayout android:id="@+id/ll_header" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginVertical="10dp" android:paddingHorizontal="10dp" android:orientation="horizontal">
|
||||
<TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.5" android:gravity="center" android:text="选项" android:textColor="@color/text_normal" android:textSize="14sp" android:textStyle="bold"/>
|
||||
<TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1.2" android:gravity="center" android:text="分单号" android:textColor="@color/text_normal" android:textSize="14sp" android:textStyle="bold"/>
|
||||
<TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.8" android:gravity="center" android:text="件数" android:textColor="@color/text_normal" android:textSize="14sp" android:textStyle="bold"/>
|
||||
@@ -100,6 +110,7 @@
|
||||
<TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.9" android:gravity="center" android:text="删除费率" android:textColor="@color/text_normal" android:textSize="14sp" android:textStyle="bold"/>
|
||||
</LinearLayout>
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/sub_list_divider"/>
|
||||
|
||||
Reference in New Issue
Block a user