From d63c74c0552db3cdab17e054150d399a00f35c6b Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 5 Jul 2021 17:09:00 +0200 Subject: [PATCH] =?UTF-8?q?Versi=C3=B3n=206.1.3=20m=C3=A1s=20textos=20camb?= =?UTF-8?q?iados=20y=20quitadas=20llamadas=20a=20collection=5FupdateState?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collection/fragment/CollectionFragment.kt | 8 +- .../feature/main/activity/MainActivity.kt | 8 +- .../pasillero/fragment/PasilleroViewModel.kt | 5 + .../precontrol/PreControladorFragment.kt | 115 ++++++++++++++++++ .../precontrol/PreControladorViewModel.kt | 43 +++++++ .../presacador/fragment/PreSacadorFragment.kt | 7 ++ .../sacador/fragment/SacadorFragment.kt | 1 - .../sacador/fragment/SacadorViewModel.kt | 5 +- .../main/res/layout/fragment_collection.xml | 6 +- app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 11 files changed, 191 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt create mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorViewModel.kt diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index d28cf171..ccb895a0 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -99,6 +99,9 @@ class CollectionFragment( override fun getLayoutId(): Int = R.layout.fragment_collection override fun onCreate(savedInstanceState: Bundle?) { + + + val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) user = prefs.getString(USER,"").toString() password = prefs.getString(PASSWORD,"").toString() @@ -135,7 +138,10 @@ class CollectionFragment( setToolBar() setEvents() - // Log.i("VERDNATURA","el type es $type") + Log.i("VERDNATURA","el type es $type") + if (type=="PRECONTROLADOR"){ + } + if (type == SACADOR && voz != "NO"){ setSpeak() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt index 2f57d6af..ce50ff21 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt @@ -32,6 +32,7 @@ import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO import es.verdnatura.presentation.view.feature.parking.fragment.ParkingFragment import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroFragment import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO +import es.verdnatura.presentation.view.feature.precontrol.PreControladorFragment import es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorFragment import es.verdnatura.presentation.view.feature.reposicion.fragment.ReposicionFragment import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorFragment @@ -188,6 +189,11 @@ class MainActivity : BaseActivity() , OnPasillerosItemClick "Pre Sacador" -> { addFragmentOnTop(PreSacadorFragment.newInstance()) } + + "Ver Ticket" -> { + addFragmentOnTop(PreControladorFragment.newInstance()) + } + "Reposición" -> { addFragmentOnTop(ReposicionFragment.newInstance()) } @@ -204,7 +210,7 @@ class MainActivity : BaseActivity() , OnPasillerosItemClick // addFragmentOnTop(BuscarItemAllFragment.newInstance(entryPoint)) // } "Historico" -> { - //addFragmentOnTop(HistoricoFragment.newInstance(entryPoint)) + addFragmentOnTop(HistoricoFragment.newInstance(entryPoint)) } "Inventario" -> { addFragmentOnTop(InventaryFragment.newInstance()) 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 8bcebfed..6a5d9e4c 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 @@ -19,6 +19,11 @@ class PasilleroViewModel(context: Context) : BaseViewModel() { R.drawable.ic_streetview_black_24dp, "Pre Sacador",R.string.PreSacador) ) + _pasillerositem.add( + PasillerosItemVO(10, + R.drawable.ic_streetview_black_24dp, + "Ver Ticket",R.string.verticket) + ) _pasillerositem.add( PasillerosItemVO(7, 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 new file mode 100644 index 00000000..59c6d850 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorFragment.kt @@ -0,0 +1,115 @@ +package es.verdnatura.presentation.view.feature.precontrol + +import android.content.Context +import android.content.SharedPreferences +import android.os.Bundle +import android.util.Log +import android.view.View +import android.view.inputmethod.EditorInfo +import androidx.lifecycle.Observer +import es.verdnatura.R +import es.verdnatura.databinding.FragmentControladorBinding +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.controlador.fragment.ControladorViewModel +import es.verdnatura.presentation.view.feature.main.activity.MainActivity +import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import kotlinx.android.synthetic.main.fragment_controlador.* +import kotlinx.android.synthetic.main.toolbar.* + +class PreControladorFragment: BaseFragment(ControladorViewModel::class) { + + + private var user = "" + private var password = "" + private var sectorFk = "" + private var warehouseFk = "" + private var goBack:Boolean = false + private var onCollectionSelectedListener : OnCollectionSelectedListener? = null + override fun getLayoutId(): Int = R.layout.fragment_controlador + private lateinit var customDialog: CustomDialog + + companion object { + fun newInstance() = PreControladorFragment() + } + + override fun onAttach(context: Context) { + super.onAttach(context) + if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context + } + + override fun init() { + + + splash_progress.visibility = View.GONE + customDialog = CustomDialog(requireContext()) + toolbar_title.text = getString(R.string.getcollection) + setEvents() + super.init() + } + + override fun onPause() { + goBack = true + super.onPause() + } + + override fun onCreate(savedInstanceState: Bundle?) { + val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) + user = prefs.getString(USER,"").toString() + password = prefs.getString(PASSWORD,"").toString() + sectorFk = prefs.getInt(SECTORFK,1).toString() + warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() + super.onCreate(savedInstanceState) + } + + private fun setEvents(){ + + scan_input.requestFocus() + scan_input.setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { + if (!scan_input.text.isNullOrEmpty()) { + splash_progress.visibility = View.VISIBLE + viewModel.collectionTicketGet( + usuario = user, + password = password, + sectorFk = sectorFk, + collectionFk = scan_input.text.toString() + ) + Log.i("VERDNATURA","La collection es ${scan_input.text.toString()}") + } + scan_input.setText("") + (activity as MainActivity).hideKeyboard(scan_input) + return@setOnEditorActionListener true + } + false + } + } + + override fun observeViewModel() { + with(viewModel){ + collectionTicketList.observe(viewLifecycleOwner, Observer { + splash_progress.visibility = View.GONE + if (it.isError){ + customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Aceptar"){ + customDialog.dismiss() + }.show() + }else{ + if (!goBack)navigateToCollectionList(it) + goBack = false + } + + }) + } + } + + private fun navigateToCollectionList(collection: CollectionVO){ + onCollectionSelectedListener?.onCollectionSelected(collection, ConstAndValues.CONTROLADOR) + //onCollectionSelectedListener?.onCollectionSelected(collection, "PRECONTROLADOR") + // onCollectionSelectedListener=null + } + + + } + diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorViewModel.kt new file mode 100644 index 00000000..ee2650e0 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/precontrol/PreControladorViewModel.kt @@ -0,0 +1,43 @@ +package es.verdnatura.presentation.view.feature.precontrol + +import android.content.Context +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import es.verdnatura.domain.GetSacadorControladorUserCase +import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.view.feature.collection.mapper.map +import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response + +class PreControladorViewModel(context: Context) : BaseViewModel() { + + private val _collectionTicketList by lazy { MutableLiveData() } + private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context) + + val collectionTicketList: LiveData + get() = _collectionTicketList + + + fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String){ + getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0").enqueue(object : + Callback { + override fun onFailure(call: Call, t: Throwable) { + _collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!) + } + override fun onResponse( + call: Call, + response: Response + ) { + if (response.body() != null){ + _collectionTicketList.value = response.body()?.let { it.map() } + }else{ + _collectionTicketList.value = CollectionVO(isError = true,errorMessage = "No hay tickets para sacar") + } + } + }) + } + + +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt index e9d81cd1..a5961699 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorFragment.kt @@ -34,6 +34,9 @@ import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyList import es.verdnatura.presentation.view.feature.sacador.model.SaleVO import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.fragment_pre_sacador.* +import kotlinx.android.synthetic.main.fragment_pre_sacador.fragment_sacador_collections +import kotlinx.android.synthetic.main.fragment_pre_sacador.splash_progress +import kotlinx.android.synthetic.main.fragment_sacador.* import kotlinx.android.synthetic.main.toolbar.* class PreSacadorFragment : BaseFragment(PreSacadorViewModel::class) { @@ -613,10 +616,14 @@ class PreSacadorFragment : BaseFragment = ArrayList() val iconPrint : Drawable = resources.getDrawable(R.drawable.ic_print_black_24dp,resources.newTheme()) val iconParking : Drawable = resources.getDrawable(R.drawable.ic_local_parking_black_24dp,resources.newTheme()) + //sergio para hacer el presacador como sacador + val iconAdd : Drawable = resources.getDrawable(R.drawable.ic_add_black_24dp,resources.newTheme()) + //val iconTransferir : Drawable = resources.getDrawable(R.drawable.ic_swap_horiz_black_24dp,resources.newTheme()) listIcons.add(iconPrint) listIcons.add(iconParking) + listIcons.add(iconAdd) //listIcons.add(iconTransferir) toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt index 6497e1a3..20ce226f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt @@ -88,7 +88,6 @@ class SacadorFragment : BaseFragment(Sa override fun onOptionsItemSelected(item: Drawable) { if(item == iconAdd){ ////Log.i("VERDNATURA","pulsando el +") - splash_progress_two.visibility = View.VISIBLE viewModel.collectionNew(user,password,sectorFk,carros) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt index bb2ff198..52981252 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt @@ -75,11 +75,8 @@ class SacadorViewModel(context: Context) : BaseViewModel() { } }) } - // fun collectionNew(usuario:String,password:String,sectorFk:String){ - // getSacadorControladorUserCase.collectionNew(usuario,password,sectorFk).enqueue(object : - fun collectionNew(usuario: String, password: String, sectorFk: String, carros: String){ - ////Log.i("VERDNATURA", "El sector para CollectionNew es $sectorFk y los carros son $carros") + fun collectionNew(usuario: String, password: String, sectorFk: String, carros: String){ getSacadorControladorUserCase.collectionNew(usuario, password, sectorFk, carros).enqueue( object : Callback { diff --git a/app/src/main/res/layout/fragment_collection.xml b/app/src/main/res/layout/fragment_collection.xml index 8bb5dc7c..9a269c13 100644 --- a/app/src/main/res/layout/fragment_collection.xml +++ b/app/src/main/res/layout/fragment_collection.xml @@ -1,7 +1,8 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + android:clickable="false"> + android:background="@color/verdnatura_black" + > diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 4895e942..b436225f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -119,4 +119,5 @@ Faltas Parking estanterías Buscar item search + Ver ticket \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f052671b..d2cc0fef 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -118,5 +118,6 @@ Faults review Shelving parking Search item test + Show ticket