diff --git a/module_base/src/main/java/com/lukouguoji/module_base/bean/GjcUldUseBean.kt b/module_base/src/main/java/com/lukouguoji/module_base/bean/GjcUldUseBean.kt index fd3b9e8..7a2ced7 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/bean/GjcUldUseBean.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/bean/GjcUldUseBean.kt @@ -1,5 +1,7 @@ package com.lukouguoji.module_base.bean +import androidx.databinding.ObservableBoolean + /** * 国际出港板箱过磅-ULD使用记录Bean * 对应API: IntExpWeighting/pageQuery @@ -54,6 +56,11 @@ class GjcUldUseBean { // ========== 出港组装页面扩展字段 ========== var isExpanded: Boolean = false // 展开状态 - var isSelected: Boolean = false // 选中状态 + val checked: ObservableBoolean = ObservableBoolean(false) // 选中状态(Observable) var waybillDetails: MutableList? = null // 运单明细缓存 + + // 兼容原有代码的isSelected属性 + var isSelected: Boolean + get() = checked.get() + set(value) = checked.set(value) } diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpOutHandoverActivity.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpOutHandoverActivity.kt index 11b08ad..83b32fb 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpOutHandoverActivity.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpOutHandoverActivity.kt @@ -29,6 +29,11 @@ class IntExpOutHandoverActivity : setBackArrow("出库交接") binding.viewModel = viewModel + // 观察全选状态,更新图标透明度 + viewModel.isAllChecked.observe(this) { isAllChecked -> + binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f + } + // 绑定分页 viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this) diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/holder/IntExpOutHandoverViewHolder.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/holder/IntExpOutHandoverViewHolder.kt index 70f8566..a2e1bf6 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/holder/IntExpOutHandoverViewHolder.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/holder/IntExpOutHandoverViewHolder.kt @@ -16,5 +16,14 @@ class IntExpOutHandoverViewHolder(view: View) : binding.bean = bean binding.position = position binding.executePendingBindings() + + // 添加图标点击事件 - 切换选择状态 + binding.ivIcon.setOnClickListener { + // 反转checked状态 + bean.checked.set(!bean.checked.get()) + + // 立即更新UI(图片自动切换) + binding.executePendingBindings() + } } } diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpOutHandoverViewModel.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpOutHandoverViewModel.kt index ff23b51..db38d65 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpOutHandoverViewModel.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpOutHandoverViewModel.kt @@ -42,7 +42,7 @@ class IntExpOutHandoverViewModel : BasePageViewModel() { // 监听全选状态,自动更新所有列表项 isAllChecked.observeForever { checked -> val list = pageModel.rv?.commonAdapter()?.items as? List ?: return@observeForever - list.forEach { it.isSelected = checked } + list.forEach { it.checked.set(checked) } pageModel.rv?.commonAdapter()?.notifyDataSetChanged() } } @@ -58,6 +58,20 @@ class IntExpOutHandoverViewModel : BasePageViewModel() { refresh() } + /** + * 全选按钮点击 (切换全选状态) + */ + fun checkAllClick() { + val list = pageModel.rv?.commonAdapter()?.items as? List ?: return + + // 切换全选状态 + val shouldCheckAll = !isAllChecked.value!! + list.forEach { it.checked.set(shouldCheckAll) } + isAllChecked.value = shouldCheckAll + + pageModel.rv?.commonAdapter()?.notifyDataSetChanged() + } + /** * 扫码ULD */ diff --git a/module_gjc/src/main/res/layout/activity_int_exp_out_handover.xml b/module_gjc/src/main/res/layout/activity_int_exp_out_handover.xml index 75f305e..ae4400d 100644 --- a/module_gjc/src/main/res/layout/activity_int_exp_out_handover.xml +++ b/module_gjc/src/main/res/layout/activity_int_exp_out_handover.xml @@ -115,16 +115,30 @@ android:gravity="center_vertical" android:paddingHorizontal="15dp"> - - + + android:gravity="center_vertical" + android:orientation="horizontal" + android:onClick="@{()-> viewModel.checkAllClick()}"> + + + + + + - - - - - - - - - - + + - + + android:layout_weight="1.5" + android:gravity="center_vertical" + android:orientation="horizontal"> - + - + - + - + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> - + - + - + - + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> - + + + + + + + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> + + + + + + + + + + + + + + + @@ -148,79 +184,130 @@ android:gravity="center_vertical" android:orientation="horizontal"> - + + android:layout_weight="1.5" + android:gravity="center_vertical" + android:orientation="horizontal"> - + - + - + - + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> - + - + - + - + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> - + + + + + + + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> + + + + + + + + + + + + + + +