feat: 国际出港/进港全选按钮新增图标切换与反向同步
- 全选/未选图标替换为新的 vector drawable,抽出 setIVCheckAllImage BindingAdapter 集中管理 - 列表项取消选中或上拉加载新数据后,左下角全选按钮自动反向同步 - 修复 isAllChecked.observeForever 反模式:导致取消单项时全部被取消、单项点击无响应 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,4 +9,11 @@ fun setIVCheckImage(imageView: ImageView, isChecked: Boolean) {
|
||||
imageView.setImageResource(
|
||||
if (isChecked) R.drawable.img_p_check_s else R.drawable.img_p_check_n
|
||||
)
|
||||
}
|
||||
|
||||
@BindingAdapter("setIVCheckAllImage")
|
||||
fun setIVCheckAllImage(imageView: ImageView, isChecked: Boolean) {
|
||||
imageView.setImageResource(
|
||||
if (isChecked) R.drawable.img_check_all_checked else R.drawable.img_check_all_unchecked
|
||||
)
|
||||
}
|
||||
@@ -117,9 +117,11 @@ class PageModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理列表数据
|
||||
* 处理列表数据。
|
||||
* onDataApplied 在 adapter.items 真正更新后回调(refresh/loadMore 都用 post 异步派发到 adapter,
|
||||
* 这里再嵌套一层 post 确保排在内部 post 之后)。
|
||||
*/
|
||||
fun handleDataList(list: List<Any>?) {
|
||||
fun handleDataList(list: List<Any>?, onDataApplied: (() -> Unit)? = null) {
|
||||
rv?.let {
|
||||
it.post {
|
||||
if (isRefresh()) {
|
||||
@@ -127,6 +129,9 @@ class PageModel {
|
||||
} else {
|
||||
it.loadMore(list)
|
||||
}
|
||||
if (onDataApplied != null) {
|
||||
it.post { onDataApplied() }
|
||||
}
|
||||
}
|
||||
}
|
||||
// 关闭加载状态
|
||||
@@ -136,9 +141,9 @@ class PageModel {
|
||||
/**
|
||||
* 处理listBean数据
|
||||
*/
|
||||
fun handleListBean(listBean: BaseListBean<*>?) {
|
||||
fun handleListBean(listBean: BaseListBean<*>?, onDataApplied: (() -> Unit)? = null) {
|
||||
loge("rv:${rv}")
|
||||
handleDataList(listBean?.list)
|
||||
handleDataList(listBean?.list, onDataApplied)
|
||||
haveMore.postValue((listBean?.pages ?: 1) > page)
|
||||
}
|
||||
|
||||
|
||||
10
module_base/src/main/res/drawable/img_check_all_checked.xml
Normal file
10
module_base/src/main/res/drawable/img_check_all_checked.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="#1C8CF5"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M512,962c-250.71428584,0 -450,-199.28571416 -450,-450s199.28571416,-450 450,-450 450,199.28571416 450,450 -199.28571416,450 -450,450zM762.71428584,306.28571416h-64.28571416c-12.85714248,0 -25.71428584,6.42857168 -32.14285752,19.28571416L454.14285752,614.85714248l-96.42857168,-128.57142832c-6.42857168,-12.85714248 -19.28571416,-19.28571416 -32.14285752,-19.28571416h-64.28571416c-6.42857168,0 -12.85714248,6.42857168 -6.42857168,12.85714248l167.14285752,231.42857168c19.28571416,25.71428584 51.42857168,25.71428584 70.71428584,0L769.14285752,319.14285752c6.42857168,-6.42857168 0,-12.85714248 -6.42857168,-12.85714336z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="#707070"
|
||||
android:pathData="M853.333333,530.962963a322.37037,322.37037 0,1 0,-322.37037 322.37037V910.222222C321.498074,910.222222 151.703704,740.427852 151.703704,530.962963S321.498074,151.703704 530.962963,151.703704s379.259259,169.79437 379.259259,379.259259 -169.79437,379.259259 -379.259259,379.259259v-56.888889a322.37037,322.37037 0,0 0,322.37037 -322.37037z"/>
|
||||
</vector>
|
||||
Reference in New Issue
Block a user