From ef32ed146143e0bc9a127fcf95251441edc885ae Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Thu, 6 Oct 2022 08:42:55 +0200 Subject: [PATCH] Version 9.2.1 Modificado fragment a fragment_general --- .../fragment/ControladorFragment.kt | 18 +- .../precontrol/PreControladorFragment.kt | 164 +++++++++--------- .../fragment/ReubicationFragment.kt | 11 +- 3 files changed, 98 insertions(+), 95 deletions(-) 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 63a4f77a..9f546417 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 @@ -2,24 +2,23 @@ package es.verdnatura.presentation.view.feature.controlador.fragment import android.content.Context import android.view.View +import android.view.View.VISIBLE import android.view.inputmethod.EditorInfo import androidx.lifecycle.Observer import es.verdnatura.R -import es.verdnatura.databinding.FragmentControladorBinding +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.main.activity.MainActivity import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO @Suppress("UNUSED_ANONYMOUS_PARAMETER") class ControladorFragment : - BaseFragment(ControladorViewModel::class) { + BaseFragment(ControladorViewModel::class) { private var goBack: Boolean = false private var onCollectionSelectedListener: OnCollectionSelectedListener? = null - override fun getLayoutId(): Int = R.layout.fragment_controlador + override fun getLayoutId(): Int = R.layout.fragment_general_black //private lateinit var customDialog: CustomDialog companion object { @@ -34,10 +33,11 @@ class ControladorFragment : override fun init() { binding.splashProgress.visibility = View.GONE - // customDialog = CustomDialog(requireContext()) + binding.scanInput.visibility = VISIBLE + binding.mainToolbar.toolbarTitle.text = getString(R.string.controlticket) setEvents() - ma.hideBottomNavigation(View.VISIBLE) + ma.hideBottomNavigation(VISIBLE) super.init() } @@ -58,7 +58,7 @@ class ControladorFragment : // d("Action id "+actionId) goBack = false if (!binding.scanInput.text.isNullOrEmpty()) { - binding.splashProgress.visibility = View.VISIBLE + binding.splashProgress.visibility = VISIBLE //sergio: para ver si ha marcado dos veces el mismo ticket. El laser falla @@ -86,7 +86,7 @@ class ControladorFragment : collectionTicketList.observe(viewLifecycleOwner, Observer { binding.splashProgress.visibility = View.GONE if (it.isError) { - ma.messageWithSound(it.errorMessage,isError = true, isPlayed = false) + ma.messageWithSound(it.errorMessage, isError = true, isPlayed = false) /*customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage) .setOkButton(getString(R.string.accept)) { customDialog.dismiss() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt index 8a0a37d0..b0347f51 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt @@ -3,10 +3,11 @@ package es.verdnatura.presentation.view.feature.precontrol import android.content.Context import android.os.Bundle import android.view.View +import android.view.View.VISIBLE import android.view.inputmethod.EditorInfo import androidx.lifecycle.Observer import es.verdnatura.R -import es.verdnatura.databinding.FragmentControladorBinding +import es.verdnatura.databinding.FragmentGeneralBlackBinding import es.verdnatura.domain.ConstAndValues import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnCollectionSelectedListener @@ -14,91 +15,92 @@ import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO @Suppress("UNUSED_ANONYMOUS_PARAMETER") -class PreControladorFragment: BaseFragment(ShowTicketViewModel::class) { - private var goBack:Boolean = false - private var onCollectionSelectedListener : OnCollectionSelectedListener? = null - override fun getLayoutId(): Int = R.layout.fragment_controlador - private var type = "" +class PreControladorFragment : + BaseFragment(ShowTicketViewModel::class) { + private var goBack: Boolean = false + private var onCollectionSelectedListener: OnCollectionSelectedListener? = null + override fun getLayoutId(): Int = R.layout.fragment_general_black + private var type = "" - companion object { - fun newInstance() = PreControladorFragment() - } + companion object { + fun newInstance() = PreControladorFragment() + } - override fun onAttach(context: Context) { - super.onAttach(context) - if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context - } + override fun onAttach(context: Context) { + super.onAttach(context) + if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context + } //sergio:Es PRECONTROLADOR PORQUE REALIZA LO MISMO QUE CONTROLADOR PERO EN EL BACK NO ACTUALIZA ESTADO Y EL CONTROLADOR SI. - override fun init() { - - binding.splashProgress.visibility = View.GONE - binding.mainToolbar.toolbarTitle.text = getString(R.string.titlePreControl) - setEvents() - super.init() - } - - override fun onPause() { - goBack = true - super.onPause() - } - - override fun onCreate(savedInstanceState: Bundle?) { - - type=ConstAndValues.PRECHECKER - super.onCreate(savedInstanceState) - } - - private fun setEvents(){ - - binding.mainToolbar.backButton.setOnClickListener { - requireActivity().onBackPressed() - } - - binding.scanInput.requestFocus() - binding.scanInput.setOnEditorActionListener { v, actionId, event -> - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { - goBack=false; - if (!binding.scanInput.text.isNullOrEmpty()) { - binding.splashProgress.visibility = View.VISIBLE - - viewModel.collectionTicketGet( - usuario = getData(USER), - password = getData(PASSWORD), - sectorFk = getData(SECTORFK), - collectionFk = binding.scanInput.text.toString(), - type = type - ) - - } - binding.scanInput.setText("") - ma.hideKeyboard(binding.scanInput) - return@setOnEditorActionListener true - } - false - } - } - - override fun observeViewModel() { - with(viewModel){ - collectionTicketList.observe(viewLifecycleOwner, Observer { - binding.splashProgress.visibility = View.GONE - if (it.isError){ - ma.messageWithSound(it.errorMessage,true,false) - - }else{ - if (!goBack)navigateToCollectionList(it) - goBack = false - } - - }) - } - } - - private fun navigateToCollectionList(collection: CollectionVO){ - onCollectionSelectedListener?.onCollectionSelected(collection, type) - } + override fun init() { + binding.splashProgress.visibility = View.GONE + binding.mainToolbar.toolbarTitle.text = getString(R.string.titlePreControl) + setEvents() + super.init() } + override fun onPause() { + goBack = true + super.onPause() + } + + override fun onCreate(savedInstanceState: Bundle?) { + + type = ConstAndValues.PRECHECKER + super.onCreate(savedInstanceState) + } + + private fun setEvents() { + binding.scanInput.visibility = VISIBLE + binding.mainToolbar.backButton.setOnClickListener { + requireActivity().onBackPressed() + } + + binding.scanInput.requestFocus() + binding.scanInput.setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { + goBack = false + if (!binding.scanInput.text.isNullOrEmpty()) { + binding.splashProgress.visibility = VISIBLE + + viewModel.collectionTicketGet( + usuario = getData(USER), + password = getData(PASSWORD), + sectorFk = getData(SECTORFK), + collectionFk = binding.scanInput.text.toString(), + type = type + ) + + } + binding.scanInput.setText("") + ma.hideKeyboard(binding.scanInput) + return@setOnEditorActionListener true + } + false + } + } + + override fun observeViewModel() { + with(viewModel) { + collectionTicketList.observe(viewLifecycleOwner, Observer { + binding.splashProgress.visibility = View.GONE + if (it.isError) { + ma.messageWithSound(it.errorMessage, true, false) + + } else { + if (!goBack) navigateToCollectionList(it) + goBack = false + } + + }) + } + } + + private fun navigateToCollectionList(collection: CollectionVO) { + onCollectionSelectedListener?.onCollectionSelected(collection, type) + } + +} + diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationFragment.kt index 3c7b3a79..a9d4d239 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationFragment.kt @@ -1,11 +1,11 @@ package es.verdnatura.presentation.view.feature.reubication.fragment import android.content.Context -import android.view.View import android.view.View.GONE +import android.view.View.VISIBLE import android.view.inputmethod.EditorInfo import es.verdnatura.R -import es.verdnatura.databinding.FragmentControladorBinding +import es.verdnatura.databinding.FragmentGeneralBlackBinding import es.verdnatura.domain.notNull import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnCollectionSelectedListener @@ -14,13 +14,13 @@ import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewMod //Tarea #3754 class ReubicationFragment(var entrypoint: String) : - BaseFragment( + BaseFragment( UbicadorViewModel::class ) { private var goBack: Boolean = false private var onCollectionSelectedListener: OnCollectionSelectedListener? = null - override fun getLayoutId(): Int = R.layout.fragment_controlador + override fun getLayoutId(): Int = R.layout.fragment_general_black private var shelvingScaned: String = "" companion object { @@ -36,6 +36,7 @@ class ReubicationFragment(var entrypoint: String) : binding.mainToolbar.toolbarTitle.text = entrypoint binding.splashProgress.visibility = GONE + binding.scanInput.visibility = VISIBLE setEvents() super.init() @@ -58,7 +59,7 @@ class ReubicationFragment(var entrypoint: String) : if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { goBack = false if (!binding.scanInput.text.isNullOrEmpty()) { - binding.splashProgress.visibility = View.VISIBLE + binding.splashProgress.visibility = VISIBLE shelvingScaned = binding.scanInput.text.toString() viewModel.itemShelving_return( usuario = getData(USER),