feat: 国际出港/进港全选按钮新增图标切换与反向同步
- 全选/未选图标替换为新的 vector drawable,抽出 setIVCheckAllImage BindingAdapter 集中管理 - 列表项取消选中或上拉加载新数据后,左下角全选按钮自动反向同步 - 修复 isAllChecked.observeForever 反模式:导致取消单项时全部被取消、单项点击无响应 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,12 +46,6 @@ class GjcAssembleAllocateActivity :
|
||||
viewModel.onItemCheckChanged()
|
||||
}
|
||||
|
||||
// 监听全选状态变化,更新图标
|
||||
viewModel.isAllChecked.observe(this) { isAllChecked ->
|
||||
// 通过alpha值表示全选状态:全选时alpha=1.0,未全选时alpha=0.5
|
||||
binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f
|
||||
}
|
||||
|
||||
// 初始化:获取分配人列表
|
||||
viewModel.getAssembleCompanyList()
|
||||
|
||||
|
||||
@@ -46,12 +46,6 @@ class GjcInspectionActivity :
|
||||
viewModel.onItemCheckChanged()
|
||||
}
|
||||
|
||||
// 监听全选状态变化,更新图标
|
||||
viewModel.isAllChecked.observe(this) { isAllChecked ->
|
||||
// 通过alpha值表示全选状态:全选时alpha=1.0,未全选时alpha=0.5
|
||||
binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f
|
||||
}
|
||||
|
||||
// 初始化代理列表
|
||||
viewModel.initAgentList()
|
||||
|
||||
|
||||
@@ -30,11 +30,6 @@ class GjcWeighingListActivity :
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 观察全选状态,更新图标透明度
|
||||
viewModel.isAllChecked.observe(this) { isAllChecked ->
|
||||
binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f
|
||||
}
|
||||
|
||||
// 初始化代理人列表(从API获取)
|
||||
viewModel.initAgentList()
|
||||
|
||||
@@ -46,6 +41,8 @@ class GjcWeighingListActivity :
|
||||
.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, getLifecycleOwner())
|
||||
|
||||
// 监听刷新事件
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).observe(this) { viewModel.onItemCheckChanged() }
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH)
|
||||
.observe(this) {
|
||||
viewModel.refresh()
|
||||
|
||||
@@ -44,11 +44,6 @@ class IntExpArriveActivity :
|
||||
viewModel.searchClick()
|
||||
}
|
||||
|
||||
// 观察全选状态,更新图标透明度
|
||||
viewModel.isAllChecked.observe(this) { isAllChecked ->
|
||||
binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f
|
||||
}
|
||||
|
||||
// 绑定分页
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
|
||||
@@ -56,6 +51,8 @@ class IntExpArriveActivity :
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
// 监听刷新事件
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).observe(this) { viewModel.onItemCheckChanged() }
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).observe(this) {
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
@@ -29,11 +29,6 @@ class IntExpLoadActivity :
|
||||
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)
|
||||
|
||||
@@ -41,6 +36,8 @@ class IntExpLoadActivity :
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
// 监听刷新事件
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).observe(this) { viewModel.onItemCheckChanged() }
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).observe(this) {
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
@@ -29,11 +29,6 @@ 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)
|
||||
|
||||
@@ -41,6 +36,8 @@ class IntExpOutHandoverActivity :
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
// 监听刷新事件
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).observe(this) { viewModel.onItemCheckChanged() }
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).observe(this) {
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
@@ -35,15 +35,12 @@ class IntExpStorageUseActivity :
|
||||
binding.viewModel = viewModel
|
||||
binding.activity = this
|
||||
|
||||
// 观察全选状态,更新图标透明度
|
||||
viewModel.isAllChecked.observe(this) { isAllChecked ->
|
||||
binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f
|
||||
}
|
||||
|
||||
// 绑定分页
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
|
||||
// 监听刷新事件
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).observe(this) { viewModel.onItemCheckChanged() }
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).observe(this) {
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
@@ -29,11 +29,6 @@ class IntExpTallyActivity :
|
||||
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)
|
||||
|
||||
@@ -41,6 +36,8 @@ class IntExpTallyActivity :
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
// 监听刷新事件
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).observe(this) { viewModel.onItemCheckChanged() }
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).observe(this) {
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
@@ -358,9 +358,9 @@ class GjcYiKuFragment : Fragment(), View.OnClickListener {
|
||||
scanCode(Constant.RequestCode.gjc_yiku_wb_no_scan)
|
||||
}
|
||||
R.id.checkIcon -> {
|
||||
//重置 isAllCheck
|
||||
isAllCheck = !isAllCheck
|
||||
resetSelCount(isAllCheck, totalCount)
|
||||
checkIcon.setImageResource(if (isAllCheck) R.drawable.img_check_all_checked else R.drawable.img_check_all_unchecked)
|
||||
}
|
||||
R.id.send -> {
|
||||
val ids = collectList.filter { c -> c.isCheck }.map { c -> c.id }
|
||||
|
||||
@@ -4,6 +4,8 @@ import android.view.View
|
||||
import com.lukouguoji.gjc.activity.GjcWeighingStartActivity
|
||||
import com.lukouguoji.gjc.databinding.ItemGjcWeighingBinding
|
||||
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.bean.GjcWeighingBean
|
||||
|
||||
/**
|
||||
@@ -22,6 +24,7 @@ class GjcWeighingViewHolder(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()
|
||||
|
||||
@@ -5,6 +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.bean.GjcMaWb
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
|
||||
@@ -24,6 +26,7 @@ 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()
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.lukouguoji.gjc.holder
|
||||
import android.view.View
|
||||
import com.lukouguoji.gjc.databinding.ItemIntExpLoadBinding
|
||||
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.bean.GjcExportLoad
|
||||
|
||||
/**
|
||||
@@ -21,6 +23,7 @@ class IntExpLoadViewHolder(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()
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.lukouguoji.gjc.holder
|
||||
import android.view.View
|
||||
import com.lukouguoji.gjc.databinding.ItemIntExpOutHandoverBinding
|
||||
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.bean.GjcUldUseBean
|
||||
|
||||
/**
|
||||
@@ -21,6 +23,7 @@ class IntExpOutHandoverViewHolder(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()
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.ItemIntExpStorageUseBinding
|
||||
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.bean.GjcMaWb
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
|
||||
@@ -25,10 +27,12 @@ class IntExpStorageUseViewHolder(view: View) :
|
||||
// 切换主列表项的选择状态
|
||||
val newCheckedState = !bean.checked.get()
|
||||
bean.checked.set(newCheckedState)
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).tryEmit("check_changed")
|
||||
|
||||
// 联动勾选/取消所有子列表项
|
||||
bean.storageUseList?.forEach { storageUse ->
|
||||
storageUse.checked.set(newCheckedState)
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).tryEmit("check_changed")
|
||||
}
|
||||
|
||||
// 刷新UI
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.ItemIntExpTallyBinding
|
||||
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.bean.GjcMaWb
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
|
||||
@@ -24,6 +26,7 @@ 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()
|
||||
|
||||
@@ -65,11 +65,6 @@ class IntExpMoveActivity : BaseBindingActivity<ActivityIntExpMoveBinding, IntExp
|
||||
* 观察数据变化
|
||||
*/
|
||||
private fun observeData() {
|
||||
// 观察全选状态,更新图标透明度
|
||||
viewModel.isAllChecked.observe(this) { isAllChecked ->
|
||||
binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f
|
||||
}
|
||||
|
||||
// 监听item选择变化事件,更新全选状态
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).observe(this) {
|
||||
viewModel.onItemCheckChanged()
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.util.CheckUtil
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
@@ -91,8 +91,7 @@ class GjcAssembleAllocateViewModel : BasePageViewModel() {
|
||||
NetApply.api.getGjcAssembleAllocateList(listParams)
|
||||
}) {
|
||||
onSuccess = { pageInfo ->
|
||||
// 直接转换为 BaseListBean
|
||||
pageModel.handleListBean(pageInfo.toBaseListBean())
|
||||
pageModel.handleListBean(pageInfo.toBaseListBean()) { updateCheckAllStatus() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class GjcInspectionViewModel : BasePageViewModel() {
|
||||
NetApply.api.getGjcInspectionList(listParams)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
pageModel.handleListBean(it) { updateCheckAllStatus() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,15 +55,15 @@ class GjcWeighingViewModel : BasePageViewModel() {
|
||||
|
||||
// 全选状态
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
|
||||
init {
|
||||
// 监听全选状态,自动更新所有列表项
|
||||
isAllChecked.observeForever { checked ->
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcWeighingBean> ?: return@observeForever
|
||||
list.forEach { it.checked.set(checked) }
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
fun onItemCheckChanged() {
|
||||
updateCheckAllStatus()
|
||||
}
|
||||
|
||||
fun updateCheckAllStatus() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcWeighingBean> ?: return
|
||||
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
@@ -210,7 +210,7 @@ class GjcWeighingViewModel : BasePageViewModel() {
|
||||
NetApply.api.getGjcWeighingList(listParams)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
pageModel.handleListBean(it) { updateCheckAllStatus() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,15 @@ class IntExpArriveViewModel : BasePageViewModel() {
|
||||
// ========== 全选状态 ==========
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
|
||||
fun onItemCheckChanged() {
|
||||
updateCheckAllStatus()
|
||||
}
|
||||
|
||||
fun updateCheckAllStatus() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcMaWb> ?: return
|
||||
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
|
||||
}
|
||||
|
||||
// ========== 全局展开状态 ==========
|
||||
/**
|
||||
* 全局展开状态
|
||||
@@ -51,15 +60,6 @@ class IntExpArriveViewModel : BasePageViewModel() {
|
||||
*/
|
||||
val isAllExpanded = MutableLiveData(false)
|
||||
|
||||
init {
|
||||
// 监听全选状态,自动更新所有列表项
|
||||
isAllChecked.observeForever { checked ->
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcMaWb> ?: return@observeForever
|
||||
list.forEach { it.checked.set(checked) }
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 适配器配置 ==========
|
||||
val itemViewHolder = IntExpArriveViewHolder::class.java
|
||||
val itemLayoutId = R.layout.item_int_exp_arrive
|
||||
@@ -312,7 +312,7 @@ class IntExpArriveViewModel : BasePageViewModel() {
|
||||
// 获取列表 (带Loading)
|
||||
launchLoadingCollect({ NetApply.api.getIntExpArriveList(listParams) }) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
pageModel.handleListBean(it) { updateCheckAllStatus() }
|
||||
// 数据加载完成后,重置全局展开状态为收起
|
||||
isAllExpanded.value = false
|
||||
}
|
||||
|
||||
@@ -43,13 +43,13 @@ class IntExpLoadViewModel : BasePageViewModel() {
|
||||
// ========== 全选状态 ==========
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
|
||||
init {
|
||||
// 监听全选状态,自动更新所有列表项
|
||||
isAllChecked.observeForever { checked ->
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcExportLoad> ?: return@observeForever
|
||||
list.forEach { it.checked.set(checked) }
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
fun onItemCheckChanged() {
|
||||
updateCheckAllStatus()
|
||||
}
|
||||
|
||||
fun updateCheckAllStatus() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcExportLoad> ?: return
|
||||
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
|
||||
}
|
||||
|
||||
// ========== 适配器配置 ==========
|
||||
@@ -215,7 +215,7 @@ class IntExpLoadViewModel : BasePageViewModel() {
|
||||
|
||||
// 获取列表 (带Loading)
|
||||
launchLoadingCollect({ NetApply.api.getIntExpLoadList(listParams) }) {
|
||||
onSuccess = { pageModel.handleListBean(it) }
|
||||
onSuccess = { pageModel.handleListBean(it) { updateCheckAllStatus() } }
|
||||
}
|
||||
|
||||
// 获取统计信息 (后台请求,不阻塞列表)
|
||||
|
||||
@@ -165,7 +165,9 @@ class IntExpMoveViewModel : BasePageViewModel(), IOnItemClickListener {
|
||||
|
||||
// 获取列表(显示loading)
|
||||
launchLoadingCollect({ NetApply.api.getIntExpMoveList(listParams) }) {
|
||||
onSuccess = { pageModel.handleListBean(it) }
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it) { updateCheckAllStatus() }
|
||||
}
|
||||
}
|
||||
|
||||
// 获取统计(后台调用)
|
||||
|
||||
@@ -39,15 +39,15 @@ class IntExpOutHandoverViewModel : BasePageViewModel() {
|
||||
|
||||
// ========== 全选状态 ==========
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
|
||||
init {
|
||||
// 监听全选状态,自动更新所有列表项
|
||||
isAllChecked.observeForever { checked ->
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcUldUseBean> ?: return@observeForever
|
||||
list.forEach { it.checked.set(checked) }
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
fun onItemCheckChanged() {
|
||||
updateCheckAllStatus()
|
||||
}
|
||||
|
||||
fun updateCheckAllStatus() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcUldUseBean> ?: return
|
||||
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
|
||||
}
|
||||
|
||||
// ========== 适配器配置 ==========
|
||||
val itemViewHolder = IntExpOutHandoverViewHolder::class.java
|
||||
@@ -182,7 +182,7 @@ class IntExpOutHandoverViewModel : BasePageViewModel() {
|
||||
|
||||
// 获取列表 (带Loading)
|
||||
launchLoadingCollect({ NetApply.api.getIntExpOutHandoverList(listParams) }) {
|
||||
onSuccess = { pageModel.handleListBean(it) }
|
||||
onSuccess = { pageModel.handleListBean(it) { updateCheckAllStatus() } }
|
||||
}
|
||||
|
||||
// 获取统计信息 (后台请求)
|
||||
|
||||
@@ -43,6 +43,15 @@ class IntExpStorageUseViewModel : BasePageViewModel() {
|
||||
// ========== 全选状态 ==========
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
|
||||
fun onItemCheckChanged() {
|
||||
updateCheckAllStatus()
|
||||
}
|
||||
|
||||
fun updateCheckAllStatus() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcMaWb> ?: return
|
||||
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
|
||||
}
|
||||
|
||||
// ========== 全局展开状态 ==========
|
||||
/**
|
||||
* 全局展开状态
|
||||
@@ -59,13 +68,6 @@ class IntExpStorageUseViewModel : BasePageViewModel() {
|
||||
KeyValue("异常", "1")
|
||||
)
|
||||
|
||||
// 监听全选状态,自动更新所有列表项
|
||||
isAllChecked.observeForever { checked ->
|
||||
val list =
|
||||
pageModel.rv?.commonAdapter()?.items as? List<GjcMaWb> ?: return@observeForever
|
||||
list.forEach { it.checked.set(checked) }
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 适配器配置 ==========
|
||||
@@ -322,7 +324,7 @@ class IntExpStorageUseViewModel : BasePageViewModel() {
|
||||
launchLoadingCollect({ NetApply.api.getIntExpStorageUseList(listParams) }) {
|
||||
onSuccess = { result ->
|
||||
// 手动处理 PageInfo 数据
|
||||
pageModel.handleDataList(result.list)
|
||||
pageModel.handleDataList(result.list) { updateCheckAllStatus() }
|
||||
pageModel.haveMore.postValue((result.pages) > pageModel.page)
|
||||
// 数据加载完成后,重置全局展开状态为收起
|
||||
isAllExpanded.value = false
|
||||
|
||||
@@ -44,6 +44,15 @@ class IntExpTallyViewModel : BasePageViewModel() {
|
||||
// ========== 全选状态 ==========
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
|
||||
fun onItemCheckChanged() {
|
||||
updateCheckAllStatus()
|
||||
}
|
||||
|
||||
fun updateCheckAllStatus() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcMaWb> ?: return
|
||||
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
|
||||
}
|
||||
|
||||
// ========== 全局展开状态 ==========
|
||||
/**
|
||||
* 全局展开状态
|
||||
@@ -52,15 +61,6 @@ class IntExpTallyViewModel : BasePageViewModel() {
|
||||
*/
|
||||
val isAllExpanded = MutableLiveData(false)
|
||||
|
||||
init {
|
||||
// 监听全选状态,自动更新所有列表项
|
||||
isAllChecked.observeForever { checked ->
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjcMaWb> ?: return@observeForever
|
||||
list.forEach { it.checked.set(checked) }
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 适配器配置 ==========
|
||||
val itemViewHolder = IntExpTallyViewHolder::class.java
|
||||
val itemLayoutId = R.layout.item_int_exp_tally
|
||||
@@ -316,7 +316,7 @@ class IntExpTallyViewModel : BasePageViewModel() {
|
||||
// 获取列表 (带Loading)
|
||||
launchLoadingCollect({ NetApply.api.getIntExpTallyList(listParams) }) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
pageModel.handleListBean(it) { updateCheckAllStatus() }
|
||||
// 数据加载完成后,重置全局展开状态为收起
|
||||
isAllExpanded.value = false
|
||||
}
|
||||
|
||||
@@ -138,10 +138,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkIcon"
|
||||
setIVCheckAllImage="@{viewModel.isAllChecked}"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -148,10 +148,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkIcon"
|
||||
setIVCheckAllImage="@{viewModel.isAllChecked}"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:onClick="@{viewModel::checkAllClick}"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
|
||||
@@ -149,9 +149,10 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkIcon"
|
||||
setIVCheckAllImage="@{viewModel.isAllChecked}"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -151,10 +151,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkIcon"
|
||||
setIVCheckAllImage="@{viewModel.isAllChecked}"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -128,10 +128,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkIcon"
|
||||
setIVCheckAllImage="@{viewModel.isAllChecked}"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -152,10 +152,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkIcon"
|
||||
setIVCheckAllImage="@{viewModel.isAllChecked}"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 统计信息 -->
|
||||
|
||||
@@ -130,10 +130,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkIcon"
|
||||
setIVCheckAllImage="@{viewModel.isAllChecked}"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -162,10 +162,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkIcon"
|
||||
setIVCheckAllImage="@{viewModel.isAllChecked}"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -152,10 +152,11 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkIcon"
|
||||
setIVCheckAllImage="@{viewModel.isAllChecked}"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:src="@drawable/img_check_all" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:src="@mipmap/gjc_check_icon" />
|
||||
android:src="@drawable/img_check_all_unchecked" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
||||
Reference in New Issue
Block a user