diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt index 3d3832e1..e754385b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorFragment.kt @@ -10,6 +10,7 @@ import es.verdnatura.databinding.FragmentGeneralBlackBinding import es.verdnatura.domain.ConstAndValues import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnCollectionSelectedListener +import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO @@ -60,46 +61,52 @@ class ControladorFragment : binding.splashProgress.visibility = VISIBLE binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) //Tarea 6458 descomentar si ok - /* collectionViewModel = CollectionViewModel(mobileApplication) - collectionViewModel!!.ticketState(binding.scanInput.text.toString().toInt()) - collectionViewModel!!.responseTicketState.observe( - viewLifecycleOwner, - Observer { it -> - binding.splashProgress.visibility = View.GONE - if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) { - var customDialogWarning = CustomDialog(requireContext()) - customDialogWarning.setTitle(getString(R.string.info)) - customDialogWarning.setDescription( - if (it.code == "ON_CHECKING") { - getString(R.string.checkingByUser, it.user.username) - } else { - getString(R.string.checkedByUser, it.user.username) - } - ) - .setOkButton(getString(R.string.aware)) { - customDialogWarning.dismiss() - binding.splashProgress.visibility= VISIBLE - viewModel.collectionTicketGet( - sectorFk = mobileApplication.dataStoreApp.readDataStoreKey( - ConstAndValues.SECTORFK - ), - collectionFk = binding.scanInput.text.toString().toInt(), - print = "0", - type = ConstAndValues.CONTROLADOR - ) - }.show() - customDialogWarning.currentFocus - } else {*/ - viewModel.collectionTicketGet( - sectorFk = mobileApplication.dataStoreApp.readDataStoreKey( - ConstAndValues.SECTORFK - ), - collectionFk = binding.scanInput.text.toString().toInt(), - print = "0", - type = ConstAndValues.CONTROLADOR - ) - // } - //}) + collectionViewModel = CollectionViewModel(mobileApplication) + collectionViewModel!!.ticketState(binding.scanInput.text.toString().toInt()) + collectionViewModel!!.responseTicketState.observe( + viewLifecycleOwner, + Observer { it -> + binding.splashProgress.visibility = View.GONE + if ((it.code == "ON_CHECKING" || it.code == "CHECKED") && it.user.id != mobileApplication.userId) { + var customDialogWarning = CustomDialog(requireContext()) + customDialogWarning.setTitle(getString(R.string.info)) + customDialogWarning.setDescription( + if (it.code == "ON_CHECKING") { + getString(R.string.checkingByUser, it.user.username) + } else { + getString(R.string.checkedByUser, it.user.username) + } + ) + .setOkButton(getString(R.string.aware)) { + customDialogWarning.dismiss() + + binding.splashProgress.visibility = VISIBLE + viewModel.collectionTicketGet( + sectorFk = mobileApplication.dataStoreApp.readDataStoreKey( + ConstAndValues.SECTORFK + ), + collectionFk = binding.scanInput.text.toString() + .toInt(), + print = "0", + type = ConstAndValues.CONTROLADOR + ) + }.setKoButton(getString(R.string.cancel)){ + binding.scanInput.setText("") + binding.scanInput.requestFocus() + customDialogWarning.dismiss() + }.show() + customDialogWarning.currentFocus + } else { + viewModel.collectionTicketGet( + sectorFk = mobileApplication.dataStoreApp.readDataStoreKey( + ConstAndValues.SECTORFK + ), + collectionFk = binding.scanInput.text.toString().toInt(), + print = "0", + type = ConstAndValues.CONTROLADOR + ) + } + }) }