Browse Source

2024-09-26 修改

修改:
1. 酒店预订 适配旧数据 部分UI逻辑修改
zhaiy 6 months ago
parent
commit
9548bf354d

+ 117 - 103
app/src/main/java/com/pan_american/android/ui/group_hotel/hotel_predetermine/HotelPredetermineBaseFragment.kt

@@ -123,15 +123,23 @@ class HotelPredetermineBaseFragment : BaseFragment<FragmentHotelPredetermineBase
 
                 binding.hotelLocation.setText(hotelAddress)
 
-                val customerSelectedId = guestName.split(",")
+                val customerSelectedId = ArrayList<String>()
+
+                if (guestName.isNotBlank()) {
+                    guestName.split(",").onEach {
+                        customerSelectedId.add(it)
+                    }
+                }
 
                 customerSelectList.clear()
 
-                for (id in customerSelectedId) {
-                    for (item in OASystem.hotelPredetermineCustomerList) {
-                        if (id.matches(Regex("[0-9]*\$"))) {
-                            if (item.id == id.toInt()) {
-                                customerSelectList.add(item)
+                if (customerSelectedId.isNotEmpty() && OASystem.hotelPredetermineCustomerList.size != 0) {
+                    for (id in customerSelectedId) {
+                        for (item in OASystem.hotelPredetermineCustomerList) {
+                            if (id.matches(Regex("[0-9]*\$"))) {
+                                if (item.id == id.toInt()) {
+                                    customerSelectList.add(item)
+                                }
                             }
                         }
                     }
@@ -390,36 +398,38 @@ class HotelPredetermineBaseFragment : BaseFragment<FragmentHotelPredetermineBase
 
         binding.nextPage.setOnClickListener {
 
-            if (hotelBaseDataVerify()) {
-                days = if(binding.checkInStartTime.text.isNotBlank() && binding.checkInEndTime.text.isNotBlank()) {
+            if (canBeEdit) {
+                if (hotelBaseDataVerify()) {
+                    days = if(binding.checkInStartTime.text.isNotBlank() && binding.checkInEndTime.text.isNotBlank()) {
 
-                    val startTime = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(binding.checkInStartTime.text.toString())
-                    val endTime = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(binding.checkInEndTime.text.toString())
+                        val startTime = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(binding.checkInStartTime.text.toString())
+                        val endTime = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(binding.checkInEndTime.text.toString())
 
-                    getGapCount(startTime!!, endTime!!)
+                        getGapCount(startTime!!, endTime!!)
 
-                } else {
-                    0
+                    } else {
+                        0
+                    }
                 }
+            }
 
-                val hotelPredeterminePaymentFragment = HotelPredeterminePaymentFragment()
+            val hotelPredeterminePaymentFragment = HotelPredeterminePaymentFragment()
 
-                val bundle = Bundle().apply {
-                    putBoolean("fromList", fromList)
-                    putBoolean("canBeEdit", canBeEdit)
-                    putInt("days", days)
-                }
+            val bundle = Bundle().apply {
+                putBoolean("fromList", fromList)
+                putBoolean("canBeEdit", canBeEdit)
+                putInt("days", days)
+            }
 
-                hotelPredeterminePaymentFragment.arguments = bundle
+            hotelPredeterminePaymentFragment.arguments = bundle
 
-                parentFragmentManager.beginTransaction().setCustomAnimations(
-                    R.anim.slide_right_in,
-                    R.anim.slide_left_out,
-                    R.anim.slide_left_in,
-                    R.anim.slide_right_out
-                ).addToBackStack(null)
-                    .add(R.id.hotel_predetermine_container, hotelPredeterminePaymentFragment).commit()
-            }
+            parentFragmentManager.beginTransaction().setCustomAnimations(
+                R.anim.slide_right_in,
+                R.anim.slide_left_out,
+                R.anim.slide_left_in,
+                R.anim.slide_right_out
+            ).addToBackStack(null)
+                .add(R.id.hotel_predetermine_container, hotelPredeterminePaymentFragment).commit()
         }
     }
 
@@ -476,106 +486,110 @@ class HotelPredetermineBaseFragment : BaseFragment<FragmentHotelPredetermineBase
 
     private fun hotelBaseDataVerify(): Boolean {
 
-        when {
-            !customerTypeSelect -> {
-                showMessage(resources.getString(R.string.customer_type_select_hint))
-                return false
-            }
+        if (canBeEdit) {
+            when {
+                !customerTypeSelect -> {
+                    showMessage(resources.getString(R.string.customer_type_select_hint))
+                    return false
+                }
 
-            !websiteSelect -> {
-                showMessage(resources.getString(R.string.website_select_hint))
-                return false
-            }
+                !websiteSelect -> {
+                    showMessage(resources.getString(R.string.website_select_hint))
+                    return false
+                }
 
-            binding.hotelConfirmCode.getText().isBlank() -> {
-                showMessage(resources.getString(R.string.hotel_confirm_code_hint))
-                return false
-            }
+                binding.hotelConfirmCode.getText().isBlank() -> {
+                    showMessage(resources.getString(R.string.hotel_confirm_code_hint))
+                    return false
+                }
 
-            binding.locatedCity.text.isNullOrBlank() -> {
-                showMessage(resources.getString(R.string.hotel_located_input_hint))
-                return false
-            }
+                binding.locatedCity.text.isNullOrBlank() -> {
+                    showMessage(resources.getString(R.string.hotel_located_input_hint))
+                    return false
+                }
 
-            binding.hotelName.text.isNullOrBlank() -> {
-                showMessage(resources.getString(R.string.hotel_name_input_hint))
-                return false
-            }
+                binding.hotelName.text.isNullOrBlank() -> {
+                    showMessage(resources.getString(R.string.hotel_name_input_hint))
+                    return false
+                }
 
-            binding.hotelTel.text.isNullOrBlank() -> {
-                showMessage(resources.getString(R.string.hotel_tel_input_hint))
-                return false
-            }
+                binding.hotelTel.text.isNullOrBlank() -> {
+                    showMessage(resources.getString(R.string.hotel_tel_input_hint))
+                    return false
+                }
 
-            binding.hotelLocation.getText().isBlank() -> {
-                showMessage(resources.getString(R.string.hotel_located_input_hint))
-                return false
-            }
+                binding.hotelLocation.getText().isBlank() -> {
+                    showMessage(resources.getString(R.string.hotel_located_input_hint))
+                    return false
+                }
 
-            customerSelectList.size == 0 -> {
-                showMessage(resources.getString(R.string.customer_select_hint))
-                return false
-            }
+                customerSelectList.size == 0 -> {
+                    showMessage(resources.getString(R.string.customer_select_hint))
+                    return false
+                }
 
-            binding.checkInStartTime.text.isNullOrBlank() -> {
-                showMessage(resources.getString(R.string.check_in_start_select_hint))
-                return false
-            }
+                binding.checkInStartTime.text.isNullOrBlank() -> {
+                    showMessage(resources.getString(R.string.check_in_start_select_hint))
+                    return false
+                }
 
-            binding.checkInEndTime.text.isNullOrBlank() -> {
-                showMessage(resources.getString(R.string.check_in_end_select_hint))
-                return false
-            }
+                binding.checkInEndTime.text.isNullOrBlank() -> {
+                    showMessage(resources.getString(R.string.check_in_end_select_hint))
+                    return false
+                }
 
-            !checkInTypeSelect -> {
-                showMessage(resources.getString(R.string.check_in_type_select_hint))
-                return false
-            }
+                !checkInTypeSelect -> {
+                    showMessage(resources.getString(R.string.check_in_type_select_hint))
+                    return false
+                }
 
-            binding.roomIntroduction.getText().isBlank() -> {
-                showMessage(resources.getString(R.string.room_introduction_hint))
-                return false
-            }
+                binding.roomIntroduction.getText().isBlank() -> {
+                    showMessage(resources.getString(R.string.room_introduction_hint))
+                    return false
+                }
 
-            else -> {
+                else -> {
 
-                OASystem.hotelPredetermineRequest.apply {
-                    diId = groupId
-                    gtId = customerTypeId
-                    reservationsWebsite = websiteId
-                    determineNo = binding.hotelConfirmCode.getText()
-                    city = binding.locatedCity.text.toString()
-                    hotelName = binding.hotelName.text.toString()
-                    hotelTel = binding.hotelTel.text.toString()
-                    hotelAddress = binding.hotelLocation.getText()
+                    OASystem.hotelPredetermineRequest.apply {
+                        diId = groupId
+                        gtId = customerTypeId
+                        reservationsWebsite = websiteId
+                        determineNo = binding.hotelConfirmCode.getText()
+                        city = binding.locatedCity.text.toString()
+                        hotelName = binding.hotelName.text.toString()
+                        hotelTel = binding.hotelTel.text.toString()
+                        hotelAddress = binding.hotelLocation.getText()
 
-                    var i = 0
-                    var idList = ""
-                    while (i < customerSelectList.size) {
+                        var i = 0
+                        var idList = ""
+                        while (i < customerSelectList.size) {
 
-                        idList += customerSelectList[i].id
-                        i += 1
+                            idList += customerSelectList[i].id
+                            i += 1
 
-                        if (i < customerSelectList.size) {
-                            idList += ","
+                            if (i < customerSelectList.size) {
+                                idList += ","
+                            }
                         }
-                    }
 
-                    guestName = idList
+                        guestName = idList
 
-                    checkInDate = binding.checkInStartTime.text.toString()
+                        checkInDate = binding.checkInStartTime.text.toString()
 
-                    checkOutDate = binding.checkInEndTime.text.toString()
+                        checkOutDate = binding.checkInEndTime.text.toString()
 
-                    checkType = checkInTypeId
+                        checkType = checkInTypeId
 
-                    roomExplanation = binding.roomIntroduction.getText()
+                        roomExplanation = binding.roomIntroduction.getText()
 
-                    hotelRemark = binding.hotelNotes.getText()
-                }
+                        hotelRemark = binding.hotelNotes.getText()
+                    }
 
-                return true
+                    return true
+                }
             }
+        } else {
+            return true
         }
     }
 }

+ 0 - 2
app/src/main/java/com/pan_american/android/ui/group_hotel/hotel_predetermine/HotelPredeterminePaymentFragment.kt

@@ -1,13 +1,11 @@
 package com.pan_american.android.ui.group_hotel.hotel_predetermine
 
-import android.content.Context
 import android.os.Bundle
 import android.text.Editable
 import android.text.TextWatcher
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
-import android.view.inputmethod.InputMethodManager
 import android.widget.TextView
 import androidx.core.content.res.ResourcesCompat
 import com.pan_american.android.OASystem