Ver código fonte

2024-04-29 修改

修改

1. 地接费用录入详情界面优化UI和部分逻辑
zhaiy 11 meses atrás
pai
commit
63fc38ae36

+ 1 - 14
.idea/deploymentTargetDropDown.xml

@@ -3,20 +3,7 @@
   <component name="deploymentTargetDropDown">
     <value>
       <entry key="app">
-        <State>
-          <runningDeviceTargetSelectedWithDropDown>
-            <Target>
-              <type value="RUNNING_DEVICE_TARGET" />
-              <deviceKey>
-                <Key>
-                  <type value="SERIAL_NUMBER" />
-                  <value value="3bb3c424" />
-                </Key>
-              </deviceKey>
-            </Target>
-          </runningDeviceTargetSelectedWithDropDown>
-          <timeTargetWasSelectedWithDropDown value="2024-04-29T02:58:46.043974100Z" />
-        </State>
+        <State />
       </entry>
     </value>
   </component>

+ 29 - 11
app/src/main/java/com/pan_american/android/ui/group_op/ground_convey_payment_insert/GroundConveyPaymentDetailActivity.kt

@@ -9,6 +9,7 @@ import android.widget.PopupWindow
 import android.widget.TextView
 import androidx.core.content.res.ResourcesCompat
 import androidx.recyclerview.widget.ConcatAdapter
+import androidx.recyclerview.widget.DiffUtil
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.StaggeredGridLayoutManager
 import com.pan_american.android.OASystem
@@ -421,6 +422,12 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
 
                                 tableInitialization[position].apply {
 
+                                    val oldList = ArrayList<GroundConveyTableItem>()
+
+                                    for (item in showItemList) {
+                                        oldList.add(item)
+                                    }
+
                                     if (isChecked) {
                                         isChecked = false
 
@@ -432,13 +439,6 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
                                             }
                                         }
 
-                                        for ((i, item) in showItemList.withIndex()) {
-                                            if (item.sId == id) {
-                                                adapter.notifyItemRemoved(i)
-                                                adapter.notifyItemRangeChanged(i, showItemList.size)
-                                            }
-                                        }
-
                                         showItemList.removeIf { item ->
                                             item.sId == id
                                         }
@@ -447,8 +447,6 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
                                         isChecked = true
                                         checkedItemId.add(id)
 
-                                        showItemList.clear()
-
                                         for ((i, item) in carTouristGuides.withIndex()) {
                                             if (item.sId == id) {
                                                 totalPrice += carTouristGuides[i].price * carTouristGuides[i].count
@@ -458,10 +456,11 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
                                                 showItemList.add(item)
                                             }
                                         }
-
-                                        adapter.notifyItemRangeChanged(0, showItemList.size)
                                     }
 
+                                    val diffUtil = DiffUtil.calculateDiff(ListRefreshCallback(oldList, showItemList))
+                                    diffUtil.dispatchUpdatesTo(adapter)
+
                                     binding.paymentTotal.text = String.format(
                                         resources.getString(R.string.price_and_currency_format),
                                         totalPrice,
@@ -708,4 +707,23 @@ class GroundConveyPaymentDetailActivity : BaseActivity<ActivityGroundConveyPayme
     private fun canBeEdit(): Boolean {
         return OASystem.authorization(OASystem.GROUND_CONVEY_PAYMENT_INSERT, OASystem.EDIT) and (isAuditGM == 0)
     }
+
+    class ListRefreshCallback(private val oldList: ArrayList<GroundConveyTableItem>, private val newList: ArrayList<GroundConveyTableItem>): DiffUtil.Callback() {
+        override fun getOldListSize(): Int {
+            return oldList.size
+        }
+
+        override fun getNewListSize(): Int {
+            return newList.size
+        }
+
+        override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
+            return oldList[oldItemPosition] == newList[newItemPosition]
+        }
+
+        override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
+            return oldList[oldItemPosition] == newList[newItemPosition]
+        }
+
+    }
 }

+ 6 - 0
app/src/main/res/layout/footer_ground_convey_payment_detail.xml

@@ -7,6 +7,12 @@
     android:orientation="vertical"
     tools:viewBindingIgnore="true">
 
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/line"
+        android:layout_margin="@dimen/common_padding"
+        android:background="@color/line_color" />
+
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"

+ 1 - 1
app/src/main/res/layout/header_ground_convey_payment_detail.xml

@@ -70,7 +70,7 @@
         android:layout_marginStart="@dimen/common_padding"
         android:layout_marginTop="@dimen/common_padding"
         android:layout_marginEnd="@dimen/common_padding"
-        android:layout_marginBottom="@dimen/common_padding_huge"
+        android:layout_marginBottom="@dimen/common_padding"
         android:orientation="horizontal">
 
         <TextView