|
@@ -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]
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|