|
@@ -1,13 +1,12 @@
|
|
|
package com.pan_american.android.ui.resource_management.airplane_three_code
|
|
|
|
|
|
import android.os.Bundle
|
|
|
+import android.view.View
|
|
|
import com.pan_american.android.OASystem
|
|
|
import com.pan_american.android.R
|
|
|
import com.pan_american.android.base.BaseActivity
|
|
|
import com.pan_american.android.base.BaseResponse
|
|
|
import com.pan_american.android.data.model.resource_management.airplane_three_code.entity.AirplaneThreeCode
|
|
|
-import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailRequest
|
|
|
-import com.pan_american.android.data.model.resource_management.airplane_three_code.network.AirplaneThreeCodeDetailResponse
|
|
|
import com.pan_american.android.data.network.APIService
|
|
|
import com.pan_american.android.data.network.ServiceCreator
|
|
|
import com.pan_american.android.databinding.ActivityAddAirplaneThreeCodeBinding
|
|
@@ -20,11 +19,7 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
|
|
|
|
|
|
private lateinit var titleBinding: LayoutTitleBinding
|
|
|
|
|
|
- private var threeCodeId = 0
|
|
|
-
|
|
|
- private val apiService = ServiceCreator.create<APIService>()
|
|
|
-
|
|
|
- private val airplaneThreeCode = AirplaneThreeCode()
|
|
|
+ private lateinit var airplaneThreeCode: AirplaneThreeCode
|
|
|
|
|
|
private var fromList = false
|
|
|
|
|
@@ -34,13 +29,7 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
|
|
|
super.onCreate(savedInstanceState)
|
|
|
screenAdaptation(binding)
|
|
|
|
|
|
- intent.apply {
|
|
|
- fromList = getBooleanExtra("fromList", false)
|
|
|
-
|
|
|
- if (fromList) {
|
|
|
- threeCodeId = getIntExtra("id", 0)
|
|
|
- }
|
|
|
- }
|
|
|
+ fromList = intent.getBooleanExtra("fromList", false)
|
|
|
|
|
|
initTitle()
|
|
|
initViews()
|
|
@@ -66,25 +55,22 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
|
|
|
|
|
|
if (fromList) {
|
|
|
|
|
|
- getAirplaneThreeCodeById()
|
|
|
+ airplaneThreeCode =
|
|
|
+ intent.getSerializableExtra("airplaneResource") as AirplaneThreeCode
|
|
|
+ initAirplaneResourceInfo()
|
|
|
|
|
|
binding.commit.setText(resources.getString(R.string.update))
|
|
|
-
|
|
|
} else {
|
|
|
|
|
|
binding.commit.setText(resources.getString(R.string.add))
|
|
|
+
|
|
|
+ airplaneThreeCode = AirplaneThreeCode()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun initEvents() {
|
|
|
|
|
|
binding.commit.setOnClickListener {
|
|
|
-
|
|
|
- if (!OASystem.authorization(OASystem.THREE_CODE_RESOURCE, OASystem.EDIT)) {
|
|
|
- back()
|
|
|
- return@setOnClickListener
|
|
|
- }
|
|
|
-
|
|
|
if (intent.getBooleanExtra("fromList", false)) {
|
|
|
initAirplaneResource(2)
|
|
|
updateAirplaneResource()
|
|
@@ -95,42 +81,7 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun getAirplaneThreeCodeById() {
|
|
|
-
|
|
|
- apiService.getAirplaneThreeCodeDetailById(AirplaneThreeCodeDetailRequest(threeCodeId)).enqueue(object : Callback<AirplaneThreeCodeDetailResponse> {
|
|
|
- override fun onResponse(
|
|
|
- call: Call<AirplaneThreeCodeDetailResponse>,
|
|
|
- response: Response<AirplaneThreeCodeDetailResponse>
|
|
|
- ) {
|
|
|
- val detailResponse = response.body()
|
|
|
-
|
|
|
- if (detailResponse != null) {
|
|
|
- if (detailResponse.code == 200) {
|
|
|
- airplaneThreeCode.apply {
|
|
|
- id = threeCodeId
|
|
|
- three = detailResponse.data.three
|
|
|
- four = detailResponse.data.four
|
|
|
- airPort = detailResponse.data.airPort
|
|
|
- airPort_En = detailResponse.data.airPort_En
|
|
|
- city = detailResponse.data.city
|
|
|
- remark = detailResponse.data.remark
|
|
|
- }
|
|
|
-
|
|
|
- initAirplaneResourceInfo()
|
|
|
- } else {
|
|
|
- showMessage(detailResponse.msg)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override fun onFailure(p0: Call<AirplaneThreeCodeDetailResponse>, p1: Throwable) {
|
|
|
- showErrorInfo(R.string.airplane_three_code_detail_get_failed)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
private fun initAirplaneResourceInfo() {
|
|
|
-
|
|
|
binding.apply {
|
|
|
threeCode.setText(airplaneThreeCode.three)
|
|
|
fourCode.setText(airplaneThreeCode.four)
|
|
@@ -149,7 +100,7 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
|
|
|
airplaneNameEn.isEnabled(false)
|
|
|
otherInfo.isEnabled(false)
|
|
|
|
|
|
- commit.setText(resources.getString(R.string.back))
|
|
|
+ commit.visibility = View.GONE
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -172,6 +123,8 @@ class AddAirplaneThreeCodeActivity : BaseActivity<ActivityAddAirplaneThreeCodeBi
|
|
|
|
|
|
binding.commit.setButtonStatus(1)
|
|
|
|
|
|
+ val apiService = ServiceCreator.create<APIService>()
|
|
|
+
|
|
|
apiService.airplaneThreeCodeOperation(airplaneThreeCode)
|
|
|
.enqueue(object : Callback<BaseResponse> {
|
|
|
override fun onResponse(
|