diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt index 59bbf845..0dd7102b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPickerNew.kt @@ -1927,10 +1927,7 @@ class CollectionFragmentPickerNew( customDialogInput.setTitle(""+sale.itemFk) .setDescription(getString(R.string.scanWagonForItem)) .setOkButton(getString(R.string.accept)) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - findSale(customDialogInput.getValue(), index, sale) - } - closeCustomDialog(binding.scanInput, customDialogInput) + findSaleAction(index, sale) }.setKoButton(getString(R.string.cancel)) { closeCustomDialog(binding.scanInput, customDialogInput) }.setValue("").show() @@ -1938,10 +1935,7 @@ class CollectionFragmentPickerNew( customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { - if (!customDialogInput.getValue().isNullOrEmpty()) { - findSale(customDialogInput.getValue(), index, sale) - } - closeCustomDialog(binding.scanInput, customDialogInput) + findSaleAction(index, sale) return@setOnEditorActionListener false } false @@ -1949,6 +1943,13 @@ class CollectionFragmentPickerNew( customDialogInput.getEditText().requestFocus() } + private fun findSaleAction(index:Int, sale:Sale) { + if (!customDialogInput.getValue().isNullOrEmpty()) { + findSale(customDialogInput.getValue(), index, sale) + } + closeCustomDialog(binding.scanInput, customDialogInput) + } + private fun closeCustomDialog(scanInput: EditText, customDialogInput: CustomDialogInput) { requireContext().hideKeyboard(customDialogInput.getEditText()) scanInput.requestFocus()