|
@@ -1,12 +1,19 @@
|
|
|
package com.pan_american.android.ui.group_hotel.hotel_predetermine
|
|
|
|
|
|
import android.os.Bundle
|
|
|
+import android.text.Editable
|
|
|
+import android.text.TextWatcher
|
|
|
+import android.view.Gravity
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
|
+import android.widget.EditText
|
|
|
+import android.widget.LinearLayout
|
|
|
+import android.widget.PopupWindow
|
|
|
import android.widget.TextView
|
|
|
import androidx.core.content.res.ResourcesCompat
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
+import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.pan_american.android.OASystem
|
|
|
import com.pan_american.android.R
|
|
|
import com.pan_american.android.base.BaseFragment
|
|
@@ -37,6 +44,10 @@ class HotelPredetermineBaseFragment : BaseFragment<FragmentHotelPredetermineBase
|
|
|
|
|
|
private var groupId = 0
|
|
|
|
|
|
+ private var countryId = 0
|
|
|
+
|
|
|
+ private var countrySelected = false
|
|
|
+
|
|
|
private var customerTypeId = 0
|
|
|
|
|
|
private var customerTypeSelect = false
|
|
@@ -115,6 +126,19 @@ class HotelPredetermineBaseFragment : BaseFragment<FragmentHotelPredetermineBase
|
|
|
|
|
|
binding.hotelConfirmCode.setText(determineNo)
|
|
|
|
|
|
+ run {
|
|
|
+ for (item in OASystem.hotelPredetermineCountries) {
|
|
|
+ if (item.id == areaId) {
|
|
|
+ binding.area.text = String.format(resources.getString(R.string.during_format), item.country, item.city)
|
|
|
+
|
|
|
+ countryId = item.id
|
|
|
+ countrySelected
|
|
|
+
|
|
|
+ return@run
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
binding.locatedCity.setText(city)
|
|
|
|
|
|
binding.hotelName.setText(hotelName)
|
|
@@ -279,6 +303,110 @@ class HotelPredetermineBaseFragment : BaseFragment<FragmentHotelPredetermineBase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ binding.area.setOnClickListener {
|
|
|
+ val selectorList = ArrayList<Selector>()
|
|
|
+
|
|
|
+ for (item in OASystem.hotelPredetermineCountries) {
|
|
|
+ selectorList.add(item)
|
|
|
+ }
|
|
|
+
|
|
|
+ val popView = View.inflate(OASystem.context, R.layout.popup_smart_refresh_selector, null)
|
|
|
+ popupWindow = PopupWindow(popView, RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT)
|
|
|
+
|
|
|
+ showPopupWindow {
|
|
|
+
|
|
|
+ val searchView: LinearLayout = popView.findViewById(R.id.search_view)
|
|
|
+ searchView.visibility = View.VISIBLE
|
|
|
+
|
|
|
+ val searchText: EditText = popView.findViewById(R.id.search_text)
|
|
|
+
|
|
|
+ selector = popView.findViewById(R.id.selector_list)
|
|
|
+
|
|
|
+ selectorContainer = popView.findViewById(R.id.selector_refresh_container)
|
|
|
+ selectorContainer.setEnableRefresh(false)
|
|
|
+ selectorContainer.setEnableLoadMore(false)
|
|
|
+
|
|
|
+ val layoutManager = LinearLayoutManager(OASystem.context)
|
|
|
+ selector.layoutManager = layoutManager
|
|
|
+
|
|
|
+ val adapter = ListAdapter.Builder<Selector>().apply {
|
|
|
+ setData(selectorList)
|
|
|
+ setLayoutId(R.layout.item_selector)
|
|
|
+ addBindView { itemView, data ->
|
|
|
+ itemView.findViewById<TextView>(R.id.selector_item_name).apply {
|
|
|
+ text = String.format(resources.getString(R.string.during_format), data.country, data.city)
|
|
|
+
|
|
|
+ if (countryId == data.id) {
|
|
|
+ setTextColor(ResourcesCompat.getColor(resources, R.color.text_color_blue, null))
|
|
|
+ } else {
|
|
|
+ setTextColor(ResourcesCompat.getColor(resources, R.color.text_color, null))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.create()
|
|
|
+
|
|
|
+ selector.adapter = adapter
|
|
|
+
|
|
|
+ adapter.onRecyclerViewItemClick =
|
|
|
+ object : ListAdapter.OnRecyclerViewItemClick<Selector> {
|
|
|
+ override fun onItemClick(position: Int) {
|
|
|
+ selectorList[position].apply {
|
|
|
+ binding.area.text = String.format(resources.getString(R.string.during_format), country, city)
|
|
|
+ binding.locatedCity.setText(city)
|
|
|
+
|
|
|
+ countryId = id
|
|
|
+ countrySelected = true
|
|
|
+
|
|
|
+ popupWindow.dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ searchText.addTextChangedListener(object : TextWatcher {
|
|
|
+ override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun afterTextChanged(editable: Editable?) {
|
|
|
+
|
|
|
+ adapter.notifyItemRangeRemoved(0, selectorList.size)
|
|
|
+
|
|
|
+ selectorList.clear()
|
|
|
+
|
|
|
+ if (editable.isNullOrBlank()) {
|
|
|
+
|
|
|
+ for (item in OASystem.hotelPredetermineCountries) {
|
|
|
+ selectorList.add(item)
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ for (i in 0 until OASystem.hotelPredetermineCountries.size) {
|
|
|
+ OASystem.hotelPredetermineCountries[i].apply {
|
|
|
+ if (country.contains(editable) || city.contains(editable)) {
|
|
|
+ selectorList.add(this)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (selectorList.size == 0) {
|
|
|
+ showMessage(resources.getString(R.string.no_data))
|
|
|
+ } else {
|
|
|
+ for (i in 0 until selectorList.size) {
|
|
|
+ adapter.notifyItemInserted(i)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ popupWindow.showAtLocation(binding.root, Gravity.BOTTOM, 0, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
binding.addCustomer.setOnClickListener {
|
|
|
showSelector {
|
|
|
val adapter = ListAdapter.Builder<Selector>().apply {
|
|
@@ -503,6 +631,11 @@ class HotelPredetermineBaseFragment : BaseFragment<FragmentHotelPredetermineBase
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
+ !countrySelected -> {
|
|
|
+ showMessage(resources.getString(R.string.area_select_hint))
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
binding.locatedCity.text.isNullOrBlank() -> {
|
|
|
showMessage(resources.getString(R.string.hotel_located_input_hint))
|
|
|
return false
|
|
@@ -555,6 +688,7 @@ class HotelPredetermineBaseFragment : BaseFragment<FragmentHotelPredetermineBase
|
|
|
gtId = customerTypeId
|
|
|
reservationsWebsite = websiteId
|
|
|
determineNo = binding.hotelConfirmCode.getText()
|
|
|
+ areaId = countryId
|
|
|
city = binding.locatedCity.text.toString()
|
|
|
hotelName = binding.hotelName.text.toString()
|
|
|
hotelTel = binding.hotelTel.text.toString()
|