diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt index 0dd10904..f914490d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoUsuarioFragment.kt @@ -52,7 +52,7 @@ class ControlVehiculoUsuarioFragment( if (userFk == vUserFK) { val androidId: String = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID) - viewModel.machineGetWorkerPlate(mobileApplication.userId!!) + // viewModel.machineGetWorkerPlate(mobileApplication.userId!!) viewModel.deviceProductionGetnameDevice( androidId ) @@ -64,7 +64,8 @@ class ControlVehiculoUsuarioFragment( binding.userInformation.visibility = INVISIBLE binding.nameVehiclecontrol.visibility = INVISIBLE binding.userImage.setOnClickListener { binding.mainToolbar.backButton.performClick() } - viewModel.machineGetWorkerPlate(mobileApplication.userId!!) + // viewModel.machineGetWorkerPlate(mobileApplication.userId!!) + binding.nameVehiclecontrol.visibility = VISIBLE viewModel.getNameWorker(userFk) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt index 2164de3e..75f67e11 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt @@ -108,35 +108,15 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) { }) } - fun machineGetWorkerPlate(userId: Int) { - salix.machineGetWorkerPlate( - arrayListOf(userId) - ).enqueue(object : SalixCallback>(context) { - override fun onSuccess(response: Response>) { - _responseMachine.value = - ResponseItemMachineControl( - response = if (response.body()!!.isEmpty()) { - "" - } else { - response.body()!![0].entrySet().first().value.toString() - .replace("\"", "") - }, - type = "getWorkerPlate" - ) - } - - }) - } - fun getNameWorker( workerId: Int ) { salix.getNameWorker( - """{"fields": ["firstName","lastName"],"where": {"id":$workerId}}""" - ).enqueue(object : SalixCallback(context) { + """{"limit":1, "where":{"id":$workerId},"skip":0,"fields":["firstName","lastName"]}""" + ).enqueue(object : SalixCallback>(context) { - override fun onSuccess(response: Response) { - _responseGetName.value = response.body() + override fun onSuccess(response: Response>) { + _responseGetName.value = response.body()?.get(0) } })