feat: 国际出港/进港子列表展开按钮始终显示并增加空状态占位
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,8 @@ import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ItemIntArrAirManifestBinding
|
||||
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.GjjAirManifest
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
|
||||
@@ -47,7 +47,23 @@ class IntArrAirManifestViewHolder(view: View) :
|
||||
R.layout.item_int_arr_air_manifest_sub
|
||||
)
|
||||
|
||||
val subList = bean.haWbList ?: emptyList()
|
||||
binding.rvSub.tag = bean
|
||||
binding.rvSub.refresh(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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,5 +45,20 @@ class IntImpStorageUseViewHolder(view: View) :
|
||||
val storageUseList = bean.storageUseList ?: emptyList()
|
||||
binding.rvSub.tag = bean
|
||||
binding.rvSub.refresh(storageUseList)
|
||||
updateSubListVisibility(storageUseList.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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,15 +41,15 @@ class IntArrAirManifestViewModel : BasePageViewModel() {
|
||||
|
||||
// ========== 全选状态 ==========
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
|
||||
fun onItemCheckChanged() {
|
||||
updateCheckAllStatus()
|
||||
}
|
||||
|
||||
fun updateCheckAllStatus() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjAirManifest> ?: return
|
||||
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
|
||||
}
|
||||
|
||||
fun onItemCheckChanged() {
|
||||
updateCheckAllStatus()
|
||||
}
|
||||
|
||||
fun updateCheckAllStatus() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjAirManifest> ?: return
|
||||
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
|
||||
}
|
||||
|
||||
// ========== 全部展开状态 ==========
|
||||
val isAllExpanded = MutableLiveData(false)
|
||||
@@ -90,9 +90,7 @@ class IntArrAirManifestViewModel : BasePageViewModel() {
|
||||
isAllExpanded.value = shouldExpand
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjAirManifest> ?: return
|
||||
list.forEach { bean ->
|
||||
if (!bean.haWbList.isNullOrEmpty()) {
|
||||
bean.showMore.set(shouldExpand)
|
||||
}
|
||||
bean.showMore.set(shouldExpand)
|
||||
}
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@@ -103,9 +103,7 @@ class IntImpStorageUseViewModel : BasePageViewModel() {
|
||||
isAllExpanded.value = shouldExpand
|
||||
|
||||
list.forEach { bean ->
|
||||
if (!bean.storageUseList.isNullOrEmpty()) {
|
||||
bean.showMore.set(shouldExpand)
|
||||
}
|
||||
bean.showMore.set(shouldExpand)
|
||||
}
|
||||
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
|
||||
Reference in New Issue
Block a user