From bd4ffa35bfb4dede7b067c6698d80b1d4bfd9a3e Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Wed, 20 Nov 2024 08:08:17 +0100 Subject: [PATCH] feat: refs #8175 refactorCode --- app/proguard-rules.pro | 2 +- .../java/es/verdnatura/MobileApplication.kt | 1 - .../presentation/base/BaseActivity.kt | 9 +- .../presentation/base/BaseFragment.kt | 8 +- .../presentation/common/GeneralAdapter.kt | 8 +- .../articulo/fragment/ItemCardFragment.kt | 3 +- .../collection/fragment/CollectionFragment.kt | 32 +++---- .../fragment/CollectionFragmentPicker.kt | 2 +- .../fragment/CollectionFragmentPickerNew.kt | 86 +++++++------------ .../fragment/CollectionFragmentPreChecker.kt | 47 +++++----- .../fragment/CollectionViewModel.kt | 22 ++++- .../fragment/ControladorFragment.kt | 2 +- .../fragments/LogExpeditionFragment.kt | 2 +- .../feature/delivery/model/InfoCompany.kt | 2 +- .../fragment/InventaryParkingFragment.kt | 23 +++-- .../view/feature/login/model/LoginItemVO.kt | 4 +- .../adapter/ExpeditionPalletAdapter.kt | 43 +++++++--- .../fragment/ExpeditionDeleteFragment.kt | 2 +- .../ExpeditionPreparedStateFragment.kt | 2 +- .../sacador/fragment/SacadorFragmentNew.kt | 8 +- .../fragment/AutomaticAddItemFragment.kt | 4 +- .../ubicador/fragment/UbicadorViewModel.kt | 65 +++++++++++++- gradle/wrapper/gradle-wrapper.properties | 4 +- 23 files changed, 225 insertions(+), 156 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 39cb9403..58f2fc33 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/app/src/main/java/es/verdnatura/MobileApplication.kt b/app/src/main/java/es/verdnatura/MobileApplication.kt index 8b81fa96..fbe56783 100644 --- a/app/src/main/java/es/verdnatura/MobileApplication.kt +++ b/app/src/main/java/es/verdnatura/MobileApplication.kt @@ -44,7 +44,6 @@ class MobileApplication : Application(), InteceptorListener { signListener = listener } - // lateinit var silex: VerdnaturaService lateinit var salix: SalixService var userId: Int? = null var userName: String? = null diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseActivity.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseActivity.kt index 7357c0a0..2ec9bf35 100644 --- a/app/src/main/java/es/verdnatura/presentation/base/BaseActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/base/BaseActivity.kt @@ -18,7 +18,7 @@ import com.google.android.gms.location.LocationCallback import com.google.android.gms.location.LocationResult import com.google.android.gms.location.Priority import es.verdnatura.MobileApplication -import timber.log.Timber.d +import es.verdnatura.domain.toast interface LocationUpdateCallback { fun onLocationReceived(location: LocationResult) @@ -36,7 +36,7 @@ abstract class BaseActivity : AppCompatActivity() { var locationUpdateCallback: LocationUpdateCallback? = null protected lateinit var binding: T - private lateinit var fusedLocationClient:FusedLocationProviderClient + private lateinit var fusedLocationClient: FusedLocationProviderClient private val locationRequest = com.google.android.gms.location.LocationRequest.Builder( Priority.PRIORITY_LOW_POWER, @@ -50,8 +50,8 @@ abstract class BaseActivity : AppCompatActivity() { setContentView(getLayoutId()) try { initDataBinding() - }catch (ex:Exception){ - d(ex.message.toString()) + } catch (ex: Exception) { + ex.message!!.toast(context = this) } mobileApplication = application as MobileApplication init() @@ -62,7 +62,6 @@ abstract class BaseActivity : AppCompatActivity() { open fun addBindingVariables() {} abstract fun init() - private fun initDataBinding() { binding = DataBindingUtil.setContentView(this, getLayoutId()) binding.lifecycleOwner = this diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt index 979ffe90..0498151d 100644 --- a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt @@ -69,10 +69,10 @@ abstract class BaseFragment( addBindingVariables() } - fun textScanned_filterDouble(textScanned: String): String { + fun textScannedFilterDouble(textScanned: String): String { if (textScanned.length > 13) { - var size = textScanned.length + val size = textScanned.length if (textScanned.substring((size / 2), size) == textScanned.substring(0, size / 2) ) { return textScanned.substring(0, size / 2) @@ -149,8 +149,8 @@ abstract class BaseFragment( fun getInfoVersionNameApp(): String { val manager: PackageManager = requireContext().packageManager val info: PackageInfo = manager.getPackageInfo(requireContext().packageName, 0) - mobileApplication.versionName = info.versionName - return info.versionName + mobileApplication.versionName = info.versionName.toString() + return mobileApplication.versionName } fun getDevicePDA(): Int? { diff --git a/app/src/main/java/es/verdnatura/presentation/common/GeneralAdapter.kt b/app/src/main/java/es/verdnatura/presentation/common/GeneralAdapter.kt index 09e1f6fe..59e04f60 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/GeneralAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/GeneralAdapter.kt @@ -8,7 +8,7 @@ import es.verdnatura.databinding.ItemGeneralRowBinding class GeneralAdapter( private var items: List, - private val onDeleteItemRowClickListener: OnGeneralItemRowClickListener, + private val onDeleteItemRowClickListener: OnGeneralItemRowClickListener? = null, private var showDelete: Boolean = false, private val onRowClickListener: OnGeneralRowClickListener? = null ) : RecyclerView.Adapter() { @@ -24,10 +24,6 @@ class GeneralAdapter( override fun onBindViewHolder(holder: ItemHolder, position: Int) { holder.bind(items[position]) - /*holder.binding.root.setOnClickListener { - onGeneralItemRowClickListener.onGeneralItemRowClickListener(items[position]) - }*/ - } inner class ItemHolder( @@ -43,7 +39,7 @@ class GeneralAdapter( itemCode.visibility = View.GONE } binding.itemImage.setOnClickListener { - onDeleteItemRowClickListener.onGeneralItemRowClickListener(item) + onDeleteItemRowClickListener?.onGeneralItemRowClickListener(item) } binding.itemCode.setOnClickListener { onRowClickListener?.onRowClickListener(item) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt index b421966f..b3b03808 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt @@ -113,8 +113,7 @@ class ItemCardFragment( listIcons.add(iconSalix) listIcons.add(iconReload) listIcons.add(iconHistory) - listIcons.add(iconPrint) - + // listIcons.add(iconPrint) binding.mainToolbar.toolbarIcons.adapter = ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener { 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 5ff7c24c..4c818e92 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 @@ -1,6 +1,5 @@ package es.verdnatura.presentation.view.feature.collection.fragment -import android.app.AlertDialog import android.content.Context import android.graphics.drawable.Drawable import android.media.MediaPlayer @@ -37,6 +36,7 @@ import es.verdnatura.domain.notNull import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.ItemScanned +import es.verdnatura.presentation.common.LabelDialogHelper import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnOptionsSelectedListener @@ -410,7 +410,7 @@ class CollectionFragment( if (!binding.scanInput.text.toString().isNullOrEmpty()) { binding.mainToolbar.toolbarIcons.visibility = VISIBLE //sergio:para ver si ha marcado dos veces el mismo ticket - binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) + binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString())) //de momento solo está el qr de artículo isScanned = @@ -969,7 +969,7 @@ class CollectionFragment( myGroupList },*/ saleAdapter = SaleAdapter( - myGroupList, + myGroupList as MutableList, pasillerosItemClickListener!!, object : OnQuantityClickListener { @@ -2276,20 +2276,20 @@ class CollectionFragment( } } if (isTicket) { - val builder = AlertDialog.Builder(context) - builder.setTitle(getString(R.string.selectLabeltoPrint)) - val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") - builder.setItems(labelCount) { dialog, which -> - viewModel.collectionStickerPrint( - collectionFk = collection.collectionFk, labelCount = (which + 1) - ) - (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( - PRINTERNAME - )).toast(requireContext()) + val labelDialogHelper = LabelDialogHelper(requireContext()) + labelDialogHelper.showLabelDialog( + onItemSelected = { labelCount -> + viewModel.collectionStickerPrint( + collectionFk = collection.collectionFk, + labelCount = labelCount + ) + + (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( + PRINTERNAME + )).toast(requireContext()) + } + ) - } - val dialog = builder.create() - dialog.show() } else { viewModel.collectionStickerPrint( collectionFk = collection.collectionFk, null diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt index 2545f799..6704e57f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt @@ -381,7 +381,7 @@ class CollectionFragmentPicker( if (!binding.scanInput.text.toString().isNullOrEmpty()) { //sergio:para ver si ha marcado dos veces el mismo ticket - binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) + binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString())) //de momento solo está el qr de artículo isScanned = 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 62929340..a27361ee 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 @@ -1,6 +1,5 @@ package es.verdnatura.presentation.view.feature.collection.fragment -import android.app.AlertDialog import android.content.Context import android.graphics.drawable.Drawable import android.media.MediaPlayer @@ -27,6 +26,7 @@ import es.verdnatura.domain.notNull import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.ItemScanned +import es.verdnatura.presentation.common.LabelDialogHelper import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnOptionsSelectedListener @@ -259,7 +259,7 @@ class CollectionFragmentPickerNew( binding.scanInput.setOnEditorActionListener { v, actionId, event -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED) if (binding.scanInput.text.toString().isNotEmpty()) { - binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) + binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString())) isScanned = event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER if (itemScanIsQr(binding.scanInput.text.toString())) { @@ -405,29 +405,6 @@ class CollectionFragmentPickerNew( } - responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner) { - - myGroupList[positionConfirm].isPicked = 1 - saleAdapter!!.notifyDataSetChanged() - lm!!.scrollToPositionWithOffset(storedPosition, 0) - /* viewModel.collectionTicketGetSalix( - collection.collectionFk, print = false - )*/ - - } - - /* - responseItemShelvingSale.observe(viewLifecycleOwner) { - myGroupList[positionConfirm].isPicked = 1 - myGroupList[positionConfirm].reservedQuantity = quantityConfirm - viewModel.collectionTicketGetSalix( - collection.collectionFk, print = false - ) - lm!!.scrollToPositionWithOffset(positionConfirm, 0) - ma.messageWithSound( - getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false - ) - }*/ loadUnpicked.observe(viewLifecycleOwner) { event -> event.getContentIfNotHandled().notNull { @@ -439,6 +416,18 @@ class CollectionFragmentPickerNew( } } + loadPicked.observe(viewLifecycleOwner) { event -> + event.getContentIfNotHandled().notNull { + if (it) { + myGroupList[positionConfirm].isPicked = 1 + saleAdapter!!.notifyItemChanged(positionConfirm) + lm!!.scrollToPositionWithOffset(positionConfirm, 0) + setTotalLines() + } else { + updateScreen() + } + } + } responseItemShelvingSaleGroup.observe(viewLifecycleOwner) { viewModel.collectionTicketGetSalix( @@ -658,7 +647,10 @@ class CollectionFragmentPickerNew( isMarking = true viewModel.itemShelvingSaleSetQuantity( - myGroupList[position].itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty + myGroupList[position].itemShelvingSaleFk, + quantity, + isItemShelvingSaleEmpty, + shelvingFk = myGroupList[position].code!! ) val mySale = sales[position].itemShelvingSaleFk @@ -869,22 +861,7 @@ class CollectionFragmentPickerNew( }.setOkButtonTwo(getString(R.string.no)) { scanRequest() customDialogThreeButtonsQuantity.dismiss() - viewModel.itemShelvingSaleExists( - myGroupList[position].itemShelvingSaleFk, - myGroupList[position].itemShelvingFk, - position, - quantity - ) - /* if (quantity == 0) { - viewModel.itemShelvingSaleExists( - myGroupList[position].itemShelvingSaleFk, - myGroupList[position].itemShelvingFk, - position, - quantity - ) - } else { - markLine(position, quantity, true) - }*/ + markLine(position, quantity, true) }.setKoButton(getString(R.string.cancel)) { scanRequest() customDialogThreeButtonsQuantity.dismiss() @@ -1108,20 +1085,19 @@ class CollectionFragmentPickerNew( } } if (isTicket) { - val builder = AlertDialog.Builder(context) - builder.setTitle(getString(R.string.selectLabeltoPrint)) - val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") - builder.setItems(labelCount) { dialog, which -> - viewModel.collectionStickerPrint( - collectionFk = collection.collectionFk, labelCount = (which + 1) - ) - (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( - PRINTERNAME - )).toast(requireContext()) + val labelDialogHelper = LabelDialogHelper(requireContext()) + labelDialogHelper.showLabelDialog( + onItemSelected = { labelCount -> + viewModel.collectionStickerPrint( + collectionFk = collection.collectionFk, + labelCount = labelCount + ) - } - val dialog = builder.create() - dialog.show() + (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( + PRINTERNAME + )).toast(requireContext()) + } + ) } else { viewModel.collectionStickerPrint( collectionFk = collection.collectionFk, null 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 8c5ff046..702e9bba 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 @@ -1,6 +1,5 @@ package es.verdnatura.presentation.view.feature.collection.fragment -import android.app.AlertDialog import android.content.Context import android.graphics.drawable.Drawable import android.media.MediaPlayer @@ -38,6 +37,7 @@ import es.verdnatura.domain.toLong import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.ItemScanned +import es.verdnatura.presentation.common.LabelDialogHelper import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnOptionsSelectedListener @@ -362,7 +362,7 @@ class CollectionFragmentPreChecker( if (!binding.scanInput.text.toString().isNullOrEmpty()) { //sergio:para ver si ha marcado dos veces el mismo ticket - binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) + binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString())) //de momento solo está el qr de artículo isScanned = @@ -399,10 +399,10 @@ class CollectionFragmentPreChecker( it.sales.forEach { at -> if (at.saleGroupFk != saleGroup) { viewModel.setParking( - ticketFk = at.saleGroupFk.toInt(), + ticketFk = at.saleGroupFk!!.toInt(), parking = myQr.more ) - saleGroup = at.saleGroupFk + saleGroup = at.saleGroupFk!! } } @@ -964,15 +964,16 @@ class CollectionFragmentPreChecker( val isOnReservationMode = mobileApplication.dataStoreApp.readDataStoreKey( ConstAndValues.RESERVATIONMODE - ) - //lolass - if (isOnReservationMode) { + ) || (mobileApplication.dataStoreApp.readDataStoreKey( + ConstAndValues.SECTORISONRESERVATIONMODE + ) == true) - sales = salesList.filter { + sales = if (isOnReservationMode) { + salesList.filter { it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK) }.sortedWith(compareBy({ it.saleOrder })) } else { - sales = salesList.filter { + salesList.filter { it.sectorFk == mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK) }.sortedWith(compareBy({ it.picked })) } @@ -983,7 +984,7 @@ class CollectionFragmentPreChecker( saleAdapter = SaleAdapter( - sales, + sales as MutableList, pasillerosItemClickListener!!, object : OnQuantityClickListener { @@ -2266,21 +2267,19 @@ class CollectionFragmentPreChecker( } } if (isTicket) { - val builder = AlertDialog.Builder(context) - builder.setTitle(getString(R.string.selectLabeltoPrint)) - val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") - builder.setItems(labelCount) { dialog, which -> - viewModel.collectionStickerPrint( - collectionFk = collection.collectionFk, - labelCount = (which + 1) - ) - (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( - PRINTERNAME - )).toast(requireContext()) + val labelDialogHelper = LabelDialogHelper(requireContext()) + labelDialogHelper.showLabelDialog( + onItemSelected = { labelCount -> + viewModel.collectionStickerPrint( + collectionFk = collection.collectionFk, + labelCount = labelCount + ) - } - val dialog = builder.create() - dialog.show() + (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( + PRINTERNAME + )).toast(requireContext()) + } + ) } else { viewModel.collectionStickerPrint( collectionFk = collection.collectionFk, 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 10bf08db..cad89ad9 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 @@ -180,8 +180,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { val loadAddNew: LiveData> = _responseNew.map { Event(it) } private val _responseCode by lazy { MutableLiveData() } - val responseCode: LiveData - get() = _responseCode + val responseCode: LiveData = _responseCode + val loadResponseCode: LiveData> = _responseCode.map { Event(it) } private val _responseIncQuantity by lazy { MutableLiveData() } val responseIncQuantity: LiveData @@ -431,10 +431,18 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { itemShelvingSaleFk: Int, quantity: Int, isItemShelvingSaleEmpty: Boolean?, - sectorFk: Int? = null + sectorFk: Int? = null, + shelvingFk: String ) { salix.itemShelvingSaleSetquantitySalix( - params = arrayListOf(itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty, sectorFk) + params = arrayListOf( + itemShelvingSaleFk, + quantity, + isItemShelvingSaleEmpty, + sectorFk, + shelvingFk + + ).formatWithQuotes() ).enqueue(object : SalixCallback(context) { override fun onSuccess(response: Response) { @@ -444,6 +452,12 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { _responseCollectionAddItem.value = true } + + override fun onError(t: Throwable) { + _responseConfirmReservedItemShelvingSale.value = false + super.onError(t) + + } }) } 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 b15ed2f5..b31c9922 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 @@ -55,7 +55,7 @@ class ControladorFragment : goBack = false if (!binding.scanInput.text.isNullOrEmpty()) { - binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) + binding.scanInput.setText(textScannedFilterDouble(binding.scanInput.text!!.toString())) try { binding.scanInput.setText( itemScanValue( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt index 22962de1..2ba86f93 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/fragments/LogExpeditionFragment.kt @@ -175,7 +175,7 @@ class LogExpeditionFragment( binding.routeLayout.visibility = View.VISIBLE binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE binding.route.text = routeDelivery.ticket.routeFk.toString() - binding.agency.text = routeDelivery.ticket.route.agencyMode.agency.name ?: "" + binding.agency.text = routeDelivery.ticket.route?.agencyMode?.agency?.name ?: "" binding.scanInput.setText("") } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/InfoCompany.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/InfoCompany.kt index c3cf8ef3..b8a70f21 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/InfoCompany.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/model/InfoCompany.kt @@ -78,7 +78,7 @@ data class Agency( class TicketSalix( var id: Int, var routeFk: Int?, - var route: RouteSalix, + var route: RouteSalix?, ) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryParkingFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryParkingFragment.kt index ecad08c3..d0dafc0c 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryParkingFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryParkingFragment.kt @@ -44,7 +44,6 @@ import es.verdnatura.presentation.view.feature.inventario.model.ItemShelvingVisi import es.verdnatura.presentation.view.feature.inventario.model.ItemShelvingVisibleZero import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO import kotlinx.coroutines.runBlocking -import timber.log.Timber.d @Suppress("UNUSED_ANONYMOUS_PARAMETER") class InventaryParkingFragment( @@ -77,13 +76,15 @@ class InventaryParkingFragment( override fun getLayoutId(): Int = R.layout.fragment_inventory_parking override fun onPause() { - try { + // try { + if (binding.inventoryParkingRecyclerview.layoutManager != null) { val layoutManager = binding.inventoryParkingRecyclerview.layoutManager as LinearLayoutManager scrollPosition = layoutManager.findFirstVisibleItemPosition() - } catch (exception: Exception) { - d(exception) } + /* } catch (ex: Exception) { + ex.message!! + "hola".toast(requireContext()) + }*/ isBack = true super.onPause() @@ -193,7 +194,7 @@ class InventaryParkingFragment( ) } catch (ex: Exception) { - d(ex) + ex.message!!.toast(requireContext()) } } @@ -475,10 +476,14 @@ class InventaryParkingFragment( ex.message!!.toast(requireContext()) } - - positionShelvingChecking = myListInventory.indexOfFirst { item -> - item.shelvingFk.uppercase() == binding.editMatricula.text.toString() + positionShelvingChecking = try { + myListInventory.indexOfFirst { item -> + item.shelvingFk.uppercase() == binding.editMatricula.text.toString() + } + } catch (ex: Exception) { + -1 } + if (positionShelvingChecking != -1) { shelvingSaved = myListInventory[positionShelvingChecking].shelvingFk.uppercase() @@ -611,7 +616,7 @@ class InventaryParkingFragment( positionShelvingChecking = -1 } catch (ex: Exception) { - d(ex) + ex.message!!.toast(requireContext()) } } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/model/LoginItemVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/model/LoginItemVO.kt index 89f4beca..fd0a2d2e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/model/LoginItemVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/model/LoginItemVO.kt @@ -18,8 +18,8 @@ data class WorkerData( val labelerFk: Int, val sectorFk: Int, val sector: Sector?, - val printer: Printer, - val train: Train, + val printer: Printer?, + val train: Train?, val id: Int, val name: String, val nickname: String, diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/adapter/ExpeditionPalletAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/adapter/ExpeditionPalletAdapter.kt index deecb558..69c64cea 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/adapter/ExpeditionPalletAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/adapter/ExpeditionPalletAdapter.kt @@ -1,7 +1,6 @@ package es.verdnatura.presentation.view.feature.paletizador.adapter import android.content.Context -import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup import androidx.core.content.ContextCompat @@ -12,47 +11,63 @@ import es.verdnatura.presentation.common.OnComprobarPalletViewClickListener import es.verdnatura.presentation.common.OnPalletClickListener import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO -import timber.log.Timber.d -class ExpeditionPalletAdapter ( +class ExpeditionPalletAdapter( private val items: List, private val onPalletClickListener: OnPalletClickListener, private val onComprobarPalletViewClickListener: OnComprobarPalletViewClickListener, private val itemExpeditionTruckVO: ItemExpeditionTruckVO -): RecyclerView.Adapter () { +) : RecyclerView.Adapter() { - private var context:Context? = null + private var context: Context? = null override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder { this.context = parent.context return ItemHolder( - ItemExpeditionpalletRowBinding.inflate(LayoutInflater.from(parent.context),parent,false) + ItemExpeditionpalletRowBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) ) } - override fun getItemCount() =items.size + override fun getItemCount() = items.size override fun onBindViewHolder(holder: ItemHolder, position: Int) { holder.bind(items[position]) holder.binding.root.setOnClickListener { - onPalletClickListener.onPalletClickListener(itemExpeditionTruckVO,items[position]) + onPalletClickListener.onPalletClickListener(itemExpeditionTruckVO, items[position]) } holder.binding.root.setOnLongClickListener { - onComprobarPalletViewClickListener.onComprobarPalletViewClickListener(itemExpeditionTruckVO,items[position]) + onComprobarPalletViewClickListener.onComprobarPalletViewClickListener( + itemExpeditionTruckVO, + items[position] + ) true } } inner class ItemHolder( val binding: ItemExpeditionpalletRowBinding - ) : RecyclerView.ViewHolder(binding.root){ + ) : RecyclerView.ViewHolder(binding.root) { private val res = binding.root.context.resources fun bind(item: ItemPalletVO) { binding.apply { this.item = item - if (item.Rutas != 1){ - expeditionPalletRutas.setTextColor(ContextCompat.getColor(context!!, R.color.verdnatura_red)) - }else { - expeditionPalletRutas.setTextColor(ContextCompat.getColor(context!!, R.color.verdnatura_white)) + if (item.Rutas != 1) { + expeditionPalletRutas.setTextColor( + ContextCompat.getColor( + context!!, + R.color.verdnatura_red + ) + ) + } else { + expeditionPalletRutas.setTextColor( + ContextCompat.getColor( + context!!, + R.color.verdnatura_white + ) + ) } } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionDeleteFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionDeleteFragment.kt index 343b0648..c32e9a95 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionDeleteFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionDeleteFragment.kt @@ -90,7 +90,7 @@ class ExpeditionDeleteFragment(var title: String = "") : if (binding.editMatricula.text.toString().isNotEmpty()) { try { val itemScaned = itemScanValue( - textScanned_filterDouble(binding.editMatricula.text.toString()), + textScannedFilterDouble(binding.editMatricula.text.toString()), arrayOf("expedition"), "id" ).toString().toLong() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPreparedStateFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPreparedStateFragment.kt index e647c0ce..71b0e93f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPreparedStateFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPreparedStateFragment.kt @@ -93,7 +93,7 @@ class ExpeditionPreparedStateFragment(var codeState: String = "PREPARED", var ti if (binding.editMatricula.text.toString().isNotEmpty()) { try { val itemScaned = itemScanValue( - textScanned_filterDouble(binding.editMatricula.text.toString()), + textScannedFilterDouble(binding.editMatricula.text.toString()), arrayOf("expedition"), "id" ).toString().toLong() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragmentNew.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragmentNew.kt index c1ba0760..0017d060 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragmentNew.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragmentNew.kt @@ -3,6 +3,7 @@ package es.verdnatura.presentation.view.feature.sacador.fragment import android.content.Context import android.graphics.drawable.Drawable import android.text.InputType +import android.util.Log.d import android.view.View import android.view.inputmethod.EditorInfo import android.widget.ImageView @@ -242,7 +243,12 @@ class SacadorFragmentNew( } else { if (it.response.isNotBlank()) { if (collectionsList.isNotEmpty()) { - addCollectionToList(it.response.toInt()) + try { + addCollectionToList(it.response.toInt()) + } catch (ex: Exception) { + d("vn", ex.message.toString()) + } + } else { callBack(type) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt index 76fc8a40..8fdab103 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemFragment.kt @@ -86,7 +86,7 @@ class AutomaticAddItemFragment( listItems.add( 0, itemScanValue( - textScanned_filterDouble(binding.editMatricula.text.toString()), + textScannedFilterDouble(binding.editMatricula.text.toString()), arrayOf("buy"), "more" ).toString().toLong() @@ -161,7 +161,7 @@ class AutomaticAddItemFragment( customDialogList.setDescription( getString(R.string.scanShelvingsLocate) ).setOkButton(getString(R.string.locate)) { - + listItems.clear() listShelvings.forEach { viewModel.itemShelvingMakeMulti( it.code!!, 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 6a204645..c4bc7586 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 @@ -70,9 +70,70 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { val loadBuyUltimateResponse: LiveData> = _buyUltimateResponse.map { Event(it) } fun itemShelvingListNew( - vShelvingFk: String + shelvingFk: String ) { - salix.itemShelvingListNew(params = listOf(vShelvingFk.uppercase()).formatWithQuotes()) + salix.itemShelvingListNew(params = listOf(shelvingFk.uppercase()).formatWithQuotes()) + .enqueue( + object : SalixCallback>(context) { + override fun onSuccess(response: Response>) { + _shelvingListNew.value = response.body()?.let { ItemUbicadorListNew(it) } + } + + }, + ) + } + + //Tarea 6869 + fun itemShelvingGet( + shelvingFk: String + ) { + salix.itemShelvingGet( + filter = """{ + "fields":[ + "priority", + "parkingFk", + "code" + ], + "include":[ + { + "relation":"parking", + "scope":{ + "fields":[ + "code" + ] + } + }, + { + "relation":"itemShelving", + "scope":{ + "fields":[ + "id", + "itemFk", + "visible", + "packing", + "grouping", + "isChecked", + "available", + "buyFk" + ], + "include":{ + "relation":"item", + "scope":{ + "fields":[ + "name", + "longName", + "size" + ] + } + } + } + } + ], + "where":{ + "code":"$shelvingFk" + } + }""".trim() + ) .enqueue( object : SalixCallback>(context) { override fun onSuccess(response: Response>) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2cf0c00f..51c22d50 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Apr 19 11:48:11 CEST 2021 +#Fri Nov 08 16:21:41 CET 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip