From 491a4f8762ebc65f0f90ec4b8cbc96ecc9c9a1bd Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Mon, 29 May 2023 12:20:57 +0200 Subject: [PATCH] refs #4940 --- .../fragment/PackingHollandFragment.kt | 68 +++++++++---------- .../pasillero/fragment/PasilleroViewModel.kt | 31 ++++----- 2 files changed, 46 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/packingHolland/fragment/PackingHollandFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/packingHolland/fragment/PackingHollandFragment.kt index 599667e4..7347231d 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/packingHolland/fragment/PackingHollandFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/packingHolland/fragment/PackingHollandFragment.kt @@ -1,7 +1,6 @@ package es.verdnatura.presentation.view.feature.packingHolland.fragment -import android.view.View.GONE -import android.view.View.VISIBLE +import android.view.View.* import android.view.inputmethod.EditorInfo import es.verdnatura.R import es.verdnatura.databinding.FragmentGeneralBlackBinding @@ -47,15 +46,11 @@ class PackingHollandFragment(var entrypoint: String) : if (!binding.scanInput.text.isNullOrEmpty()) { try { - - binding.scanInput.setText( - itemScanValue( - binding.scanInput.text.toString(), - "buy", - "more" - ).toString() - ) - shelvingScaned = binding.scanInput.text.toString().toInt() + shelvingScaned = itemScanValue( + binding.scanInput.text.toString(), + "buy", + "more" + ).toString().toInt() showQuantityPacking() } catch (ex: Exception) { ex.message!!.toast(requireActivity()) @@ -76,9 +71,9 @@ class PackingHollandFragment(var entrypoint: String) : response.observe(viewLifecycleOwner) { binding.splashProgress.visibility = GONE if (it.isError) { - ma.messageWithSound(it.errorMessage, true, false) + ma.messageWithSound(it.errorMessage, true, true) } else { - showQuantityPacking() + ma.messageWithSound(it.errorMessage, false, true, isToasted = false) } } @@ -94,49 +89,48 @@ class PackingHollandFragment(var entrypoint: String) : customDialogInput.setDescription(getString(R.string.packingQuantity) + shelvingScaned) .setValue("") .setOkButton(getString(R.string.modify)) { - - if (customDialogInput.getValue().isNotEmpty() - ) { - callPacking(customDialogInput.getValue()) - } - - + callPacking(customDialogInput.getValue()) }.setKoButton(getString(R.string.cancel)) { customDialogInput.dismiss() }.show() customDialogInput.setFocusText() - - - customDialogInput.setFocusText() ma.hideKeyboard(customDialogInput.getEditText()) customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) { - if (customDialogInput.getValue().isNotEmpty()) { - callPacking(customDialogInput.getValue()) - } + callPacking(customDialogInput.getValue()) return@setOnEditorActionListener true } false } - + ma.hideKeyboard(customDialogInput.getEditText()) } - private fun callPacking(value: String) { - try { - binding.splashProgress.visibility = VISIBLE - viewModel.travel_updatePacking( - itemFk = shelvingScaned, - packingFk = value.toInt() - ) - } catch (ex: Exception) { - getString(R.string.errorInput).toast(requireActivity()) + private fun callPacking(value: String) { + if (customDialogInput.getValue().isNotEmpty()) { + + try { + + ma.hideKeyboard(customDialogInput.getEditText()) + customDialogInput.dismiss() + binding.splashProgress.visibility = VISIBLE + viewModel.travel_updatePacking( + itemFk = shelvingScaned, + packingFk = value.toInt() + ) + + + } catch (ex: Exception) { + binding.splashProgress.visibility = INVISIBLE + getString(R.string.errorInput).toast(requireActivity()) + customDialogInput.setValue("") + } + } - customDialogInput.setValue("") } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt index 1fc4243e..c30dfedb 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt @@ -120,7 +120,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) //Tarea 4940 - /* _pasillerositem.add( + _pasillerositem.add( PasillerosItemVO( 1, R.drawable.ic_packaging, @@ -130,21 +130,9 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { R.string.titleUbicatorDescrip ) ) - )*/ - - //Tarea 5095 - _pasillerositem.add( - PasillerosItemVO( - 1, - R.drawable.ic_shopping_self, - contextApp.getString(R.string.selfConsumption), - R.string.titleSelfConsumption, - contextApp.getString( - R.string.titleSelfConsumption - ) - ) ) + //Tarea 4979 /* _pasillerositem.add( PasillerosItemVO( @@ -252,6 +240,17 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) ) ) + _pasillerositem.add( + PasillerosItemVO( + 1, + R.drawable.ic_shopping_self, + contextApp.getString(R.string.selfConsumption), + R.string.titleSelfConsumption, + contextApp.getString( + R.string.titleSelfConsumption + ) + ) + ) } @@ -502,7 +501,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { //#tarea4679 - /* _pasillerositem.add( + _pasillerositem.add( PasillerosItemVO( 6, R.drawable.ic_delivery_truck, @@ -510,7 +509,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { R.string.titleDelivery, contextApp.getString(R.string.titleDeliveryDescrip) ) - )*/ + ) //#tarea4021 /* _pasillerositem.add(