diff --git a/CLAUDE.md b/CLAUDE.md index d224524..780bb74 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -848,5 +848,10 @@ grep -A 5 "enum class DataLayoutType" module_base/src --include="*.kt" --- **签名配置**: `key.jks` / 密码: `123321` / 别名: `key` -- 后面统一使用PadDataLayoutNew 而不是PadDataLayout 控件 -- 当使用PadDataLayoutNew 控件的时候,titleLength 通常设置为5 \ No newline at end of file +- 当使用PadDataLayoutNew 控件的时候,titleLength 通常设置为5 +- 在每个页面布局时,我会给你截图,请务必尽可能还原图片上的页面设计,而不是推测、假想。如果有困难(例如图片看不清,不明白的地方)一律要询问我,禁止自己想象。 +- layout xml 最佳布局实践参考: + - module_gjc/src/main/res/layout/activity_gjc_weighing_record_details.xml + - module_gjc/src/main/res/layout/item_gjc_check_in_record.xml + - module_gjc/src/main/res/layout/activity_gjc_box_weighing_details.xml + - module_gjc/src/main/res/layout/activity_gjc_inspection.xml \ No newline at end of file diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcCheckInRecordViewHolder.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcCheckInRecordViewHolder.kt index d2024cd..562247f 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcCheckInRecordViewHolder.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcCheckInRecordViewHolder.kt @@ -1,5 +1,7 @@ package com.lukouguoji.gjc.holder +import android.text.Editable +import android.text.TextWatcher import android.view.View import com.lukouguoji.gjc.databinding.ItemGjcCheckInRecordBinding import com.lukouguoji.module_base.base.BaseViewHolder @@ -12,6 +14,8 @@ class GjcCheckInRecordViewHolder(view: View) : BaseViewHolder(view) { private var isEditMode: Boolean = false + private var pcTextWatcher: TextWatcher? = null + private var weightTextWatcher: TextWatcher? = null fun updateEditMode(editMode: Boolean) { this.isEditMode = editMode @@ -23,17 +27,29 @@ class GjcCheckInRecordViewHolder(view: View) : binding.isEditMode = isEditMode binding.position = position // 传入位置用于显示序号 - // 设置refreshCallBack来捕获用户输入的变化 - if (isEditMode) { - binding.padPc.refreshCallBack = { - val pcStr = binding.padPc.value - record.pc = pcStr.toLongOrNull() ?: 0L - } + // 移除旧的监听器 + pcTextWatcher?.let { binding.etPc.removeTextChangedListener(it) } + weightTextWatcher?.let { binding.etWeight.removeTextChangedListener(it) } - binding.padWeight.refreshCallBack = { - val weightStr = binding.padWeight.value - record.weight = weightStr.toDoubleOrNull() ?: 0.0 + // 在编辑模式下监听EditText输入 + if (isEditMode) { + pcTextWatcher = object : TextWatcher { + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {} + override fun afterTextChanged(s: Editable?) { + record.pc = s?.toString()?.toLongOrNull() ?: 0L + } } + binding.etPc.addTextChangedListener(pcTextWatcher) + + weightTextWatcher = object : TextWatcher { + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {} + override fun afterTextChanged(s: Editable?) { + record.weight = s?.toString()?.toDoubleOrNull() ?: 0.0 + } + } + binding.etWeight.addTextChangedListener(weightTextWatcher) } binding.executePendingBindings() diff --git a/module_gjc/src/main/res/drawable/bg_circle_green.xml b/module_gjc/src/main/res/drawable/bg_circle_green.xml new file mode 100644 index 0000000..b2cf3f3 --- /dev/null +++ b/module_gjc/src/main/res/drawable/bg_circle_green.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/module_gjc/src/main/res/layout/activity_gjc_weighing_record_details.xml b/module_gjc/src/main/res/layout/activity_gjc_weighing_record_details.xml index de2cc1d..b712db1 100644 --- a/module_gjc/src/main/res/layout/activity_gjc_weighing_record_details.xml +++ b/module_gjc/src/main/res/layout/activity_gjc_weighing_record_details.xml @@ -1,6 +1,7 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> @@ -30,159 +31,202 @@ android:orientation="horizontal" android:padding="15dp"> - - + + android:orientation="horizontal"> - - + + + + + + + android:orientation="horizontal"> - - + + + + + + + android:orientation="horizontal"> - - + + + + + + + android:orientation="horizontal"> + + + + + + + + - - + - - + + android:text="@{`总件数:` + viewModel.totalPc}" + android:textColor="@color/text_gray" + android:textSize="16sp" /> - - + + android:layout_marginStart="20dp" + android:text="@{`总重量:` + viewModel.totalWeight}" + android:textColor="@color/text_gray" + android:textSize="16sp" /> - - + + android:layout_marginStart="20dp" + android:text="@{`重量误差: ` + viewModel.weightError}" + android:textColor="@color/text_red" + android:textSize="16sp" /> - + + + + + android:layout_centerInParent="true" + android:orientation="horizontal" + android:visibility="@{viewModel.isEditMode ? View.VISIBLE : View.GONE}"> - - - - + + android:text="取消" /> - + + android:text="保存" /> - + diff --git a/module_gjc/src/main/res/layout/item_gjc_check_in_record.xml b/module_gjc/src/main/res/layout/item_gjc_check_in_record.xml index ebe7f39..77fb588 100644 --- a/module_gjc/src/main/res/layout/item_gjc_check_in_record.xml +++ b/module_gjc/src/main/res/layout/item_gjc_check_in_record.xml @@ -3,7 +3,7 @@ - + - - + + - - + + android:orientation="horizontal"> - - + + + + + + + + + + + android:orientation="horizontal"> - - + + + + + + + + + + + android:orientation="horizontal"> - - + + + + + + + android:orientation="horizontal"> + + + + +