From ccf56fdebfae4ee4d0ad608754722c6288e0f1e6 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Tue, 29 Oct 2024 08:59:33 +0100 Subject: [PATCH] feat: refs #8020 controlVehiculos --- .../ControlVehiculoUsuarioFragment.kt | 5 ++-- .../fragment/ControlVehiculoViewModel.kt | 28 +++---------------- 2 files changed, 7 insertions(+), 26 deletions(-) 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) } })