|
@@ -10,6 +10,8 @@ import com.pan_american.android.base.BaseActivity
|
|
|
import com.pan_american.android.base.BaseResponse
|
|
|
import com.pan_american.android.base.ListAdapter
|
|
|
import com.pan_american.android.data.model.resource_management.car_resource.entity.CarResource
|
|
|
+import com.pan_american.android.data.model.resource_management.car_resource.network.CarResourceDetailRequest
|
|
|
+import com.pan_american.android.data.model.resource_management.car_resource.network.CarResourceDetailResponse
|
|
|
import com.pan_american.android.data.network.APIService
|
|
|
import com.pan_american.android.data.network.ServiceCreator
|
|
|
import com.pan_american.android.databinding.ActivityAddCarResourceBinding
|
|
@@ -28,13 +30,21 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
|
|
|
|
|
|
private var fromList = false
|
|
|
|
|
|
+ private var apiService = ServiceCreator.create<APIService>()
|
|
|
+
|
|
|
+ private var resourceId = 0
|
|
|
+
|
|
|
override fun getViewBinding() = ActivityAddCarResourceBinding.inflate(layoutInflater)
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
screenAdaptation(binding)
|
|
|
|
|
|
- fromList = intent.getBooleanExtra("fromList", false)
|
|
|
+ intent.apply {
|
|
|
+ fromList = this.getBooleanExtra("fromList", false)
|
|
|
+ resourceId = this.getIntExtra("resource_id", 0)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
initTitle()
|
|
|
initViews()
|
|
@@ -61,8 +71,6 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
|
|
|
|
|
|
if (fromList) {
|
|
|
|
|
|
- carResource = intent.getSerializableExtra("carResource") as CarResource
|
|
|
-
|
|
|
initCarResourceInfo()
|
|
|
|
|
|
binding.commit.setText(resources.getString(R.string.update))
|
|
@@ -209,77 +217,100 @@ class AddCarResourceActivity : BaseActivity<ActivityAddCarResourceBinding>() {
|
|
|
}
|
|
|
|
|
|
private fun initCarResourceInfo() {
|
|
|
- binding.apply {
|
|
|
- carCompany.setText(carResource.unitName)
|
|
|
- for (item in OASystem.score) {
|
|
|
- if (item == carResource.score.toString()) {
|
|
|
- companyScore.text = carResource.score.toString()
|
|
|
- isChose = true
|
|
|
- }
|
|
|
- }
|
|
|
- departmentArea.setText(carResource.unitArea)
|
|
|
- departmentLocation.setText(carResource.address)
|
|
|
- contactsName.setText(carResource.contact)
|
|
|
- contactsPhone.setText(carResource.contactTel)
|
|
|
- contactsEmail.setText(carResource.contactEmail)
|
|
|
- contactsFax.setText(carResource.contactFax)
|
|
|
- carDescription.setText(carResource.carDes)
|
|
|
- otherInfo.setText(carResource.otherInfo)
|
|
|
- }
|
|
|
|
|
|
- when (carResource.qualificationScore) {
|
|
|
- "A" -> binding.carQualificationA.isChecked = true
|
|
|
- "B" -> binding.carQualificationB.isChecked = true
|
|
|
- "C" -> binding.carQualificationC.isChecked = true
|
|
|
- }
|
|
|
+ apiService.getCarResourceDetailById(CarResourceDetailRequest(resourceId)).enqueue(object : Callback<CarResourceDetailResponse> {
|
|
|
+ override fun onResponse(
|
|
|
+ call: Call<CarResourceDetailResponse>,
|
|
|
+ response: Response<CarResourceDetailResponse>
|
|
|
+ ) {
|
|
|
+ val resourceResponse = response.body()
|
|
|
+
|
|
|
+ if (resourceResponse != null) {
|
|
|
+ if (resourceResponse.code == 200) {
|
|
|
+ carResource = resourceResponse.data
|
|
|
+
|
|
|
+ binding.apply {
|
|
|
+ carCompany.setText(carResource.unitName)
|
|
|
+ for (item in OASystem.score) {
|
|
|
+ if (item == carResource.score.toString()) {
|
|
|
+ companyScore.text = carResource.score.toString()
|
|
|
+ isChose = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ departmentArea.setText(carResource.unitArea)
|
|
|
+ departmentLocation.setText(carResource.address)
|
|
|
+ contactsName.setText(carResource.contact)
|
|
|
+ contactsPhone.setText(carResource.contactTel)
|
|
|
+ contactsEmail.setText(carResource.contactEmail)
|
|
|
+ contactsFax.setText(carResource.contactFax)
|
|
|
+ carDescription.setText(carResource.carDes)
|
|
|
+ otherInfo.setText(carResource.otherInfo)
|
|
|
+ }
|
|
|
|
|
|
- when (carResource.carAgeScore) {
|
|
|
- "A" -> binding.carAgeA.isChecked = true
|
|
|
- "B" -> binding.carAgeB.isChecked = true
|
|
|
- "C" -> binding.carAgeC.isChecked = true
|
|
|
- }
|
|
|
+ when (carResource.qualificationScore) {
|
|
|
+ "A" -> binding.carQualificationA.isChecked = true
|
|
|
+ "B" -> binding.carQualificationB.isChecked = true
|
|
|
+ "C" -> binding.carQualificationC.isChecked = true
|
|
|
+ }
|
|
|
|
|
|
- when (carResource.cleanImgScore) {
|
|
|
- "A" -> binding.carSurfaceA.isChecked = true
|
|
|
- "B" -> binding.carSurfaceB.isChecked = true
|
|
|
- "C" -> binding.carSurfaceC.isChecked = true
|
|
|
- }
|
|
|
+ when (carResource.carAgeScore) {
|
|
|
+ "A" -> binding.carAgeA.isChecked = true
|
|
|
+ "B" -> binding.carAgeB.isChecked = true
|
|
|
+ "C" -> binding.carAgeC.isChecked = true
|
|
|
+ }
|
|
|
|
|
|
- when (carResource.smellScore) {
|
|
|
- "A" -> binding.carInnerA.isChecked = true
|
|
|
- "B" -> binding.carInnerB.isChecked = true
|
|
|
- "C" -> binding.carInnerC.isChecked = true
|
|
|
- }
|
|
|
+ when (carResource.cleanImgScore) {
|
|
|
+ "A" -> binding.carSurfaceA.isChecked = true
|
|
|
+ "B" -> binding.carSurfaceB.isChecked = true
|
|
|
+ "C" -> binding.carSurfaceC.isChecked = true
|
|
|
+ }
|
|
|
|
|
|
- when (carResource.waterPaperScore) {
|
|
|
- "A" -> binding.carPrepareA.isChecked = true
|
|
|
- "B" -> binding.carPrepareB.isChecked = true
|
|
|
- "C" -> binding.carPrepareC.isChecked = true
|
|
|
- }
|
|
|
+ when (carResource.smellScore) {
|
|
|
+ "A" -> binding.carInnerA.isChecked = true
|
|
|
+ "B" -> binding.carInnerB.isChecked = true
|
|
|
+ "C" -> binding.carInnerC.isChecked = true
|
|
|
+ }
|
|
|
|
|
|
- when (carResource.hardwareScore) {
|
|
|
- "A" -> binding.carDisposeA.isChecked = true
|
|
|
- "B" -> binding.carDisposeB.isChecked = true
|
|
|
- "C" -> binding.carDisposeC.isChecked = true
|
|
|
- }
|
|
|
+ when (carResource.waterPaperScore) {
|
|
|
+ "A" -> binding.carPrepareA.isChecked = true
|
|
|
+ "B" -> binding.carPrepareB.isChecked = true
|
|
|
+ "C" -> binding.carPrepareC.isChecked = true
|
|
|
+ }
|
|
|
|
|
|
- when (carResource.timeScore) {
|
|
|
- "A" -> binding.timeConceptA.isChecked = true
|
|
|
- "B" -> binding.timeConceptB.isChecked = true
|
|
|
- "C" -> binding.timeConceptC.isChecked = true
|
|
|
- }
|
|
|
+ when (carResource.hardwareScore) {
|
|
|
+ "A" -> binding.carDisposeA.isChecked = true
|
|
|
+ "B" -> binding.carDisposeB.isChecked = true
|
|
|
+ "C" -> binding.carDisposeC.isChecked = true
|
|
|
+ }
|
|
|
|
|
|
- when (carResource.safetyScore) {
|
|
|
- "A" -> binding.safetyConceptA.isChecked = true
|
|
|
- "B" -> binding.safetyConceptB.isChecked = true
|
|
|
- "C" -> binding.safetyConceptC.isChecked = true
|
|
|
- }
|
|
|
+ when (carResource.timeScore) {
|
|
|
+ "A" -> binding.timeConceptA.isChecked = true
|
|
|
+ "B" -> binding.timeConceptB.isChecked = true
|
|
|
+ "C" -> binding.timeConceptC.isChecked = true
|
|
|
+ }
|
|
|
|
|
|
- when (carResource.drivingAgeScore) {
|
|
|
- "A" -> binding.driverA.isChecked = true
|
|
|
- "B" -> binding.driverB.isChecked = true
|
|
|
- "C" -> binding.driverC.isChecked = true
|
|
|
- }
|
|
|
+ when (carResource.safetyScore) {
|
|
|
+ "A" -> binding.safetyConceptA.isChecked = true
|
|
|
+ "B" -> binding.safetyConceptB.isChecked = true
|
|
|
+ "C" -> binding.safetyConceptC.isChecked = true
|
|
|
+ }
|
|
|
+
|
|
|
+ when (carResource.drivingAgeScore) {
|
|
|
+ "A" -> binding.driverA.isChecked = true
|
|
|
+ "B" -> binding.driverB.isChecked = true
|
|
|
+ "C" -> binding.driverC.isChecked = true
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ showMessage(resourceResponse.msg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onFailure(call: Call<CarResourceDetailResponse>, t: Throwable) {
|
|
|
+ showErrorInfo(R.string.car_resource_detail_get_failed)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
/**
|