From eb787e04cc6ade4c429ffe57a8555fe17f896991 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Wed, 26 Jun 2024 12:35:04 +0200 Subject: [PATCH] feat crashlytics refs #6810 --- .../presentation/common/SalixBackItems.kt | 2 +- .../collection/fragment/CollectionFragment.kt | 13 ++-- .../fragment/CollectionFragmentPreChecker.kt | 16 +++-- .../fragment/CollectionViewModel.kt | 2 +- .../delivery/fragments/RoutesFragment.kt | 10 +-- .../delivery/fragments/TicketsFragment.kt | 33 +++++++--- .../ubicador/fragment/UbicadorFragmentNew.kt | 62 ++++++++++++++----- .../ubicador/fragment/UbicadorViewModel.kt | 12 ++-- app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 12 files changed, 108 insertions(+), 46 deletions(-) diff --git a/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt b/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt index f377c7e2..30ed4f38 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/SalixBackItems.kt @@ -20,7 +20,7 @@ data class SaleTrackingSalix( var code: String, var isChecked: Boolean, var buyFk: Long, - var isScanned: Boolean, + var isScanned: Boolean?, var quantity: Int, var itemShelvingFk: Int 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 ef69fb96..a73e1dde 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 @@ -2147,10 +2147,15 @@ class CollectionFragment( try { customDialogThreeButtons.setDescription(getString(R.string.itemSaleQuantity)) - .setValue("").setOkButtonAdd(getString(R.string.Agregar)) { - increaseQuantity(position, customDialogThreeButtons.getValue().toInt()) - scanRequest() - customDialogThreeButtons.dismiss() + .setValue("").setOkButtonAdd(getString(R.string.modify)) { + try { + increaseQuantity(position, customDialogThreeButtons.getValue().toInt()) + scanRequest() + customDialogThreeButtons.dismiss() + }catch (ex:Exception){ + ma.messageWithSound(message = getString(R.string.errorInputQuantity), isPlayed = true, isError = true, isToasted = true) + } + }.setKoButton(getString(R.string.cancel)) { scanRequest() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt index d4f19d5e..5f717968 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt @@ -36,6 +36,7 @@ import es.verdnatura.domain.ConstAndValues.SACADOR import es.verdnatura.domain.ConstAndValues.SECTORDESCRIP import es.verdnatura.domain.ConstAndValues.SECTORFK import es.verdnatura.domain.notNull +import es.verdnatura.domain.toLong import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.ItemScanned @@ -417,11 +418,16 @@ class CollectionFragmentPreChecker( } else { storedBackPosition = 0 storedPosition = 0 - viewModel.getSales( - binding.scanInput.text.toString().toInt(), - print = "0", - source = type - ) + try { + viewModel.getSales( + binding.scanInput.toLong(), + print = "0", + source = type + ) + }catch (ex:Exception){ + ma.messageWithSound(message = getString(R.string.errorInput), isError = true, isPlayed = true, isToasted = true) + } + // findSale(binding.scanInput.text.toString()) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt index 496e5450..53859026 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt @@ -206,7 +206,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { get() = _responseSaleAddPrevOK fun getSales( - collectionFk: Int, print: String, source: String + collectionFk: Number, print: String, source: String ) { salix.getSalesFromTicketOrCollection( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt index 00aa4759..161537ca 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/RoutesFragment.kt @@ -210,11 +210,13 @@ class RoutesFragment( } private fun filteredList(searchText: String) { + if (::myListRoute.isInitialized) { + val filteredList = myListRoute.filter { route -> + route.toString().lowercase().contains(searchText) + }.toMutableList() + adapter!!.updateList(filteredList) + } - val filteredList = myListRoute.filter { route -> - route.toString().lowercase().contains(searchText) - }.toMutableList() - adapter!!.updateList(filteredList) } override fun observeViewModel() { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt index 47146091..570e004b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/TicketsFragment.kt @@ -7,6 +7,7 @@ import android.content.Intent import android.content.pm.PackageManager import android.graphics.drawable.Drawable import android.net.Uri +import android.os.Bundle import android.view.View import android.widget.ImageView import android.widget.TextView @@ -50,11 +51,11 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.Calendar -class TicketsFragment( - var title: String = "", var route: RouteInfo, -) : BaseFragment( +class TicketsFragment : BaseFragment( DeliveryViewModel::class ) { + private var title: String? = null + private lateinit var route: RouteInfo private var adapter: TicketAdapter? = null private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null @@ -67,13 +68,31 @@ class TicketsFragment( private var firstVisibleItemPosition = -1 companion object { - fun newInstance(title: String, entryPoint: String) = - TicketsFragment(title, Gson().fromJson(entryPoint, RouteInfo::class.java)) - +//Tarea 6810 revisar fallos app + private const val ARG_TITLE = "title" + private const val ARG_ROUTE = "route" private const val REQUEST_CALL_PERMISSION = 1 - } + fun newInstance(title: String, entryPoint: String) = + TicketsFragment().apply { + arguments = Bundle().apply { + putString(ARG_TITLE, title) + putString(ARG_ROUTE, entryPoint) + } + } + + /* fun newInstance(title: String, entryPoint: String) = + TicketsFragment(title, Gson().fromJson(entryPoint, RouteInfo::class.java))*/ + + } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + arguments?.let { + title = it.getString(ARG_TITLE) + route = Gson().fromJson(it.getString(ARG_ROUTE), RouteInfo::class.java) + } + } override fun getLayoutId(): Int = R.layout.fragment_tickets override fun init() { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragmentNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragmentNew.kt index c631a1a8..b6826e5c 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragmentNew.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragmentNew.kt @@ -3,6 +3,7 @@ package es.verdnatura.presentation.view.feature.ubicador.fragment import android.annotation.SuppressLint import android.content.Context import android.graphics.drawable.Drawable +import android.os.Bundle import android.text.InputType import android.text.TextWatcher import android.view.View @@ -15,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R import es.verdnatura.databinding.FragmentUbicadorBinding import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK +import es.verdnatura.domain.isShelving import es.verdnatura.domain.notNull import es.verdnatura.domain.toInt import es.verdnatura.domain.toast @@ -33,14 +35,14 @@ import es.verdnatura.presentation.view.component.CustomDialogUbicadorNew import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapterNew import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador -import java.lang.Boolean.TRUE + @Suppress("UNUSED_ANONYMOUS_PARAMETER") -class UbicadorFragmentNew( - var shelvingFk: String = "", var isAutoSelf: Boolean -) : BaseFragment( +class UbicadorFragmentNew: BaseFragment( UbicadorViewModel::class ) { + private var shelvingFk: String = "" + private var isAutoSelf: Boolean = false private var adapter: UbicadorAdapterNew? = null private lateinit var customDialogInput: CustomDialogInput @@ -58,12 +60,30 @@ class UbicadorFragmentNew( private var isBack = false var listIcons: ArrayList = ArrayList() private lateinit var textWatcher: TextWatcher - private var buyScanned :String = "" + private var buyScanned: String = "" companion object { - fun newInstance(entryPoint: String, autoSelf: Boolean = false) = - UbicadorFragmentNew(entryPoint, autoSelf) + private const val ARG_SHELVINGFK = "shelvingFk" + private const val ARG_ISAUTOSELF = "autoSelf" + fun newInstance(shelvingFk: String, isAutoSelf: Boolean = false) = + UbicadorFragmentNew().apply { + arguments = Bundle().apply { + putString(ARG_SHELVINGFK, shelvingFk) + putBoolean(ARG_ISAUTOSELF, isAutoSelf) + } + } } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + arguments?.let { + shelvingFk = it.getString(ARG_SHELVINGFK).toString() + isAutoSelf = it.getBoolean(ARG_ISAUTOSELF) + } + } + + /*fun newInstance(entryPoint: String, autoSelf: Boolean = false) = + UbicadorFragmentNew(entryPoint, autoSelf) + }*/ override fun getLayoutId(): Int = R.layout.fragment_ubicador override fun onPause() { @@ -236,7 +256,10 @@ class UbicadorFragmentNew( if (binding.editMatricula.text.toString().isNotEmpty()) { setIconsActions(true) setIcons() - if (!modeCheckUbication || (modeCheckUbication && binding.editMatricula.text.toString().length == 3 && !binding.editMatricula.text!![0].isDigit())) { + if (!modeCheckUbication || (modeCheckUbication + && (binding.editMatricula.text.toString().isShelving()) + && !binding.editMatricula.text!![0].isDigit()) + ) { binding.mainToolbar.toolbarTitle.text = binding.editMatricula.text.toString() shelvingFk = binding.editMatricula.text.toString() @@ -425,7 +448,11 @@ class UbicadorFragmentNew( val listInt: ArrayList = ArrayList() if (listItems.none { it.item == itemScanned }) { - listInt.add(buyScanned.toLong()) + try { + listInt.add(buyScanned.toLong()) + } catch (_: Exception) { + } + } else { listItems.sortedBy { it.isChecked }.forEachIndexed { index, item -> if (item.item == itemScanned) { @@ -442,12 +469,14 @@ class UbicadorFragmentNew( } } - viewModel.itemShelvingAddList( - shelvingFk, - "" + listInt + "", - TRUE, - mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK) - ) + if (listInt.isNotEmpty()) { + viewModel.itemShelvingAddList( + shelvingFk, + "" + listInt + "", + true, + mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK) + ) + } adapter!!.notifyDataSetChanged() } @@ -514,7 +543,8 @@ class UbicadorFragmentNew( } loadResponseCode.observe(viewLifecycleOwner) { event -> event.getContentIfNotHandled().notNull { - if (it != 0) checkUbications((it as Long)) + //not always is true + if (it!=null)checkUbications((it as Long)) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt index 7abadbf7..5bb4d03f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt @@ -61,11 +61,11 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { val loadReubicationList: LiveData> = _reubicationList.map { Event(it) } - private val _responseCode by lazy { MutableLiveData() } - val responseCode: LiveData + private val _responseCode by lazy { MutableLiveData() } + val responseCode: LiveData get() = _responseCode - val loadResponseCode: LiveData> = _responseCode.map { Event(it) } + val loadResponseCode: LiveData> = _responseCode.map { Event(it) } private val _responseAddList by lazy { MutableLiveData() } val responseAddList: LiveData = _responseAddList @@ -405,11 +405,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { override fun onSuccess(response: Response) { - _responseCode.value = if (response.body() == null) { - 0 - } else { - response.body().toString().toLong() - } + _responseCode.value = response.body() } }) diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 5684bc1b..080e75ad 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -833,5 +833,6 @@ Escanea parking Revisar sacado por cajas Hoy quedan por salir %1$x unidades + Error al introducir cantidad diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d4aceaee..fc73d1a0 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -833,5 +833,6 @@ Escanea parking Revisar sacado por cajas Hoy quedan por salir %1$x unidades + Error al introducir cantidad diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 2ec72462..2a2d3b70 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -833,5 +833,6 @@ Escanea parking Revisar sacado por cajas Hoy quedan por salir %1$x unidades + Error al introducir cantidad diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 841ea964..ecaa6648 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -835,5 +835,6 @@ Escanea parking Revisar sacado por cajas Hoy quedan por salir %1$x unidades + Error al introducir cantidad