From e458f8a174375be877ed9273056af490a33c5b16 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 5 Nov 2021 08:12:23 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1adida=20toast=20de=20respuesta=20cuando?= =?UTF-8?q?=20se=20modifica=20prioridad=20y=20quitado=20response.body=3D?= =?UTF-8?q?=3Dnull=20en=20UbicadorFragment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetDropDown.xml | 17 +++++++++++++++++ .../ubicador/fragment/UbicadorFragment.kt | 11 +++++++++++ .../ubicador/fragment/UbicadorViewModel.kt | 18 +++++++++++++++--- 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 00000000..8b8cbbca --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt index 065573b7..2f67e53e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt @@ -292,6 +292,17 @@ class UbicadorFragment( } }) + responsepriority.observe(viewLifecycleOwner, Observer { + if (it.isError){ + mperror!!.start() + customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){ + customDialog.dismiss() + }.show() + }else{ + (it.response).toast(requireContext()) + } + }) + responseMake.observe(viewLifecycleOwner, Observer { if (!shelvingFk.isNullOrEmpty()){ splash_progress.visibility = View.VISIBLE diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt index 6ae2c277..25a48b68 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt @@ -27,6 +27,11 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { val response: LiveData get() = _response + private val _responsepriority by lazy { MutableLiveData() } + val responsepriority: LiveData + get() = _responsepriority + + private val _responseMake by lazy { MutableLiveData() } val responseMake: LiveData get() = _responseMake @@ -63,15 +68,22 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { fun shelvingPriorityUpdate(usuario:String,password:String,priority:String,shelving:String,callFunction:String){ getUbicadorUserCase.shelvingPriorityUpdate(usuario,password,priority,shelving).enqueue(object : Callback{ override fun onFailure(call: Call, t: Throwable) { - _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) + _responsepriority.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)) } override fun onResponse(call: Call, response: Response) { - if (response.body() == null){ + + if (!response.isSuccessful){ + _responsepriority.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) + }else{ + _responsepriority.value = ResponseItemVO(isError = false,response = "Prioridad modificada") + } + + /*if (response.body() == null){ _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())) }else{ _response.value = ResponseItemVO(isError = false,response = response.body()!!) - } + }*/ }