|
@@ -3,10 +3,15 @@ package com.pan_american.android.ui.group_airplane_ticket.airplane_payment_inser
|
|
|
import android.os.Bundle
|
|
|
import android.text.Editable
|
|
|
import android.text.TextWatcher
|
|
|
+import android.view.Gravity
|
|
|
import android.view.View
|
|
|
+import android.view.ViewGroup
|
|
|
+import android.widget.PopupWindow
|
|
|
import android.widget.TextView
|
|
|
import androidx.core.content.res.ResourcesCompat
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
+import com.bin.david.form.core.SmartTable
|
|
|
+import com.bin.david.form.data.style.FontStyle
|
|
|
import com.pan_american.android.OASystem
|
|
|
import com.pan_american.android.R
|
|
|
import com.pan_american.android.base.BaseActivity
|
|
@@ -15,7 +20,11 @@ import com.pan_american.android.base.CardAdapter
|
|
|
import com.pan_american.android.base.ListAdapter
|
|
|
import com.pan_american.android.data.model.common.entity.CardPaymentResource
|
|
|
import com.pan_american.android.data.model.common.entity.Selector
|
|
|
+import com.pan_american.android.data.model.common.network.GroupCostDataRequest
|
|
|
+import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.entity.AirplaneCost
|
|
|
+import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.entity.AirplaneItinerary
|
|
|
import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.entity.AirplaneTicketResource
|
|
|
+import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.network.AirplaneCostDetailResponse
|
|
|
import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.network.AirplaneTicketDetailRequest
|
|
|
import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.network.AirplaneTicketDetailResponse
|
|
|
import com.pan_american.android.data.model.group_airplane_ticket.airplane_payment_insert.network.AirplaneTicketSelectorResourceRequest
|
|
@@ -93,6 +102,16 @@ class AddAirplaneTicketActivity : BaseActivity<ActivityAddAirplaneTicketBinding>
|
|
|
|
|
|
private var isAuditGM = -1
|
|
|
|
|
|
+ private var airplaneCostInit = false
|
|
|
+
|
|
|
+ private var airplaneCostCurrency = ""
|
|
|
+
|
|
|
+ private var airplaneCostExchangeRate = 0.0
|
|
|
+
|
|
|
+ private var airplaneCostList = ArrayList<AirplaneCost>()
|
|
|
+
|
|
|
+ private var airplaneItineraryList = ArrayList<AirplaneItinerary>()
|
|
|
+
|
|
|
override fun getViewBinding() = ActivityAddAirplaneTicketBinding.inflate(layoutInflater)
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@@ -129,9 +148,88 @@ class AddAirplaneTicketActivity : BaseActivity<ActivityAddAirplaneTicketBinding>
|
|
|
titleText.text = resources.getString(R.string.add_airplane_ticket_payment)
|
|
|
}
|
|
|
|
|
|
+ rightTextField.apply {
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ text = resources.getString(R.string.show_cost)
|
|
|
+ }
|
|
|
+
|
|
|
backButton.setOnClickListener {
|
|
|
back()
|
|
|
}
|
|
|
+
|
|
|
+ rightTextField.setOnClickListener {
|
|
|
+
|
|
|
+ val airplaneCostPopView = View.inflate(OASystem.context, R.layout.popup_airplane_cost_table, null)
|
|
|
+ popupWindow = PopupWindow(airplaneCostPopView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
|
+
|
|
|
+ showPopupWindow {
|
|
|
+
|
|
|
+ val currencyAbbr = airplaneCostPopView.findViewById<TextView>(R.id.currency_abbr)
|
|
|
+ val exchangeRate = airplaneCostPopView.findViewById<TextView>(R.id.exchange_rate)
|
|
|
+ val airplaneCostTable = airplaneCostPopView.findViewById<SmartTable<AirplaneCost>>(R.id.airplane_cost_table)
|
|
|
+ val airplaneItineraryTable = airplaneCostPopView.findViewById<SmartTable<AirplaneItinerary>>(R.id.airplane_itinerary_table)
|
|
|
+
|
|
|
+ airplaneCostTable.config.apply {
|
|
|
+ isShowXSequence = false
|
|
|
+ isShowYSequence = false
|
|
|
+ tableTitleStyle = FontStyle(50, ResourcesCompat.getColor(resources, R.color.text_color, theme))
|
|
|
+ contentStyle = FontStyle(40, ResourcesCompat.getColor(resources, R.color.text_color, theme))
|
|
|
+ }
|
|
|
+
|
|
|
+ airplaneItineraryTable.config.apply {
|
|
|
+ isShowXSequence = false
|
|
|
+ isShowYSequence = false
|
|
|
+ tableTitleStyle = FontStyle(50, ResourcesCompat.getColor(resources, R.color.text_color, theme))
|
|
|
+ contentStyle = FontStyle(40, ResourcesCompat.getColor(resources, R.color.text_color, theme))
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!airplaneCostInit) {
|
|
|
+ apiService.getAirplaneCostData(GroupCostDataRequest(groupId, OASystem.C_TABLE_AIRPLANE_TICKET)).enqueue(object : Callback<AirplaneCostDetailResponse> {
|
|
|
+ override fun onResponse(
|
|
|
+ call: Call<AirplaneCostDetailResponse>,
|
|
|
+ response: Response<AirplaneCostDetailResponse>
|
|
|
+ ) {
|
|
|
+
|
|
|
+ val costResponse = response.body()
|
|
|
+
|
|
|
+ if (costResponse != null) {
|
|
|
+ if (costResponse.code == 200) {
|
|
|
+
|
|
|
+ airplaneCostCurrency = costResponse.data.modulePromptInfos[0].currencyCode
|
|
|
+ airplaneCostExchangeRate = costResponse.data.modulePromptInfos[0].rate
|
|
|
+
|
|
|
+ airplaneCostList = costResponse.data.modulePromptInfos[0].data.airFeeData
|
|
|
+ airplaneItineraryList = costResponse.data.modulePromptInfos[0].data.airInitData
|
|
|
+
|
|
|
+ currencyAbbr.text = airplaneCostCurrency
|
|
|
+ exchangeRate.text = airplaneCostExchangeRate.toString()
|
|
|
+
|
|
|
+ airplaneCostTable.setData(airplaneCostList)
|
|
|
+ airplaneItineraryTable.setData(airplaneItineraryList)
|
|
|
+
|
|
|
+ airplaneCostInit = true
|
|
|
+
|
|
|
+ } else {
|
|
|
+ showMessage(costResponse.msg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onFailure(call: Call<AirplaneCostDetailResponse>, t: Throwable) {
|
|
|
+ showErrorInfo(R.string.airplane_cost_get_failed)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ currencyAbbr.text = airplaneCostCurrency
|
|
|
+ exchangeRate.text = airplaneCostExchangeRate.toString()
|
|
|
+
|
|
|
+ airplaneCostTable.setData(airplaneCostList)
|
|
|
+ airplaneItineraryTable.setData(airplaneItineraryList)
|
|
|
+ }
|
|
|
+
|
|
|
+ popupWindow.showAtLocation(binding.root, Gravity.BOTTOM, 0, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|