feat inventoryParking #refs 6193
This commit is contained in:
parent
915aad5a32
commit
6a5817844e
|
@ -39,6 +39,7 @@ object ConstAndValues {
|
|||
const val SUPPLIERID = "SUPPLIERID"
|
||||
const val SUPPLIERNAME = "SUPPLIERNAME"
|
||||
const val ENTRYID = "ENTRYID"
|
||||
const val ENTRYOBSERVATIONORIGINAL = "ENTRYOBSERVATIONORIGINAL"
|
||||
const val ITEMPACKING = "itemPackingType"
|
||||
const val ITEMPACKINGFK = "itemPackingTypeFk"
|
||||
const val BUYER = "buyernickname"
|
||||
|
@ -60,6 +61,9 @@ object ConstAndValues {
|
|||
const val RENEWINTERVAL = "renewInterval"
|
||||
const val RENEWPERIOD = "renewPeriod"
|
||||
const val MENUBYDEFAULTSELECTED = "MENUBYDEFAULTSELECTED"
|
||||
const val INVENTORYPARKINGTO = "INVENTORYPARKINGTO"
|
||||
const val INVENTORYPARKINGFROM = "INVENTORYPARKINGFROM"
|
||||
const val LIMITRECORDSSHELVINGLOG = 25
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,15 @@ package es.verdnatura.presentation.view.feature.inventario.fragment
|
|||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ImageView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.OnBackPressedDispatcher
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -16,9 +20,12 @@ import com.google.gson.JsonArray
|
|||
import com.google.gson.JsonObject
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentInventoryParkingBinding
|
||||
import es.verdnatura.domain.ConstAndValues.INVENTORYPARKINGFROM
|
||||
import es.verdnatura.domain.ConstAndValues.INVENTORYPARKINGTO
|
||||
import es.verdnatura.domain.notNull
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnBackPressedListener
|
||||
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
|
||||
import es.verdnatura.presentation.common.OnMoreClickListener
|
||||
import es.verdnatura.presentation.common.OnOptionsSelectedListener
|
||||
|
@ -36,6 +43,7 @@ import es.verdnatura.presentation.view.feature.inventario.model.ItemShelvingChec
|
|||
import es.verdnatura.presentation.view.feature.inventario.model.ItemShelvingVisible
|
||||
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")
|
||||
|
@ -43,7 +51,7 @@ class InventaryParkingFragment(
|
|||
var title: String = "",
|
||||
) : BaseFragment<FragmentInventoryParkingBinding, InventaryViewModel>(
|
||||
InventaryViewModel::class
|
||||
) {
|
||||
), OnBackPressedListener {
|
||||
private var adapter: InventoryParkingAdapter? = null
|
||||
private lateinit var customDialogInput: CustomDialogInput
|
||||
private lateinit var customDialogList: CustomDialogList
|
||||
|
@ -60,6 +68,7 @@ class InventaryParkingFragment(
|
|||
private var filterActivated = false
|
||||
private var shelvingSaved = ""
|
||||
val listIcons: ArrayList<ImageView> = ArrayList()
|
||||
private lateinit var backDispatcher: OnBackPressedDispatcher
|
||||
|
||||
companion object {
|
||||
fun newInstance(title: String) = InventaryParkingFragment(title)
|
||||
|
@ -102,6 +111,22 @@ class InventaryParkingFragment(
|
|||
super.init()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
requireActivity().onBackPressedDispatcher.addCallback(
|
||||
viewLifecycleOwner,
|
||||
object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (!onBackPressedHandled()) {
|
||||
isEnabled = false
|
||||
requireActivity().onBackPressedDispatcher
|
||||
} else {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun setViews() {
|
||||
binding.inventoryParkingRecyclerview.addOnScrollListener(object :
|
||||
RecyclerView.OnScrollListener() {
|
||||
|
@ -193,12 +218,12 @@ class InventaryParkingFragment(
|
|||
}
|
||||
|
||||
})
|
||||
chageListAdapter(listIcons.filter { it != iconReset })
|
||||
changeListAdapter(listIcons.filter { it != iconReset })
|
||||
binding.mainToolbar.toolbarIcons.layoutManager =
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
}
|
||||
|
||||
private fun chageListAdapter(filterList: List<ImageView>, removeReset: Boolean = false) {
|
||||
private fun changeListAdapter(filterList: List<ImageView>, removeReset: Boolean = false) {
|
||||
if (!removeReset) {
|
||||
(binding.mainToolbar.toolbarIcons.adapter as ToolBarAdapterTooltip).setItemsList(
|
||||
filterList
|
||||
|
@ -278,8 +303,30 @@ class InventaryParkingFragment(
|
|||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
listParkings = ArrayList()
|
||||
customDialogList.dismiss()
|
||||
}.setValue("").show()
|
||||
|
||||
}.setValue("")
|
||||
if (mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
INVENTORYPARKINGFROM
|
||||
).isNotEmpty()
|
||||
) {
|
||||
customDialogList.setOkButton(
|
||||
getString(
|
||||
R.string.lastChecking, mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
INVENTORYPARKINGFROM
|
||||
), mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
INVENTORYPARKINGTO
|
||||
)
|
||||
)
|
||||
) {
|
||||
reviewParkings(
|
||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
INVENTORYPARKINGFROM
|
||||
), mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||
INVENTORYPARKINGTO
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
customDialogList.show()
|
||||
customDialogList.getEditText().requestFocus()
|
||||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
|
||||
|
@ -289,15 +336,30 @@ class InventaryParkingFragment(
|
|||
try {
|
||||
|
||||
if (listParkings.size == 1) {
|
||||
callGetInventory(
|
||||
|
||||
/* callGetInventory(
|
||||
listParkings.first().code!!.uppercase(),
|
||||
customDialogList.getValue().uppercase()
|
||||
)*/
|
||||
|
||||
runBlocking {
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
INVENTORYPARKINGFROM,
|
||||
listParkings.first().code!!
|
||||
)
|
||||
mobileApplication.dataStoreApp.editDataStoreKey(
|
||||
INVENTORYPARKINGTO,
|
||||
customDialogList.getValue()
|
||||
)
|
||||
}
|
||||
reviewParkings(
|
||||
listParkings.first().code!!.uppercase(),
|
||||
customDialogList.getValue().uppercase()
|
||||
)
|
||||
|
||||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
/*ma.hideKeyboard(customDialogList.getEditText())
|
||||
listParkings.clear()
|
||||
customDialogList.dismiss()
|
||||
binding.editMatricula.requestFocus()
|
||||
binding.editMatricula.requestFocus()*/
|
||||
} else {
|
||||
customDialogList.setDescription(getString(R.string.selectParkingsTo))
|
||||
listParkings.add(0, BarcodeVO(code = customDialogList.getValue()))
|
||||
|
@ -336,6 +398,17 @@ class InventaryParkingFragment(
|
|||
|
||||
}
|
||||
|
||||
private fun reviewParkings(parkingFrom: String, parkingTo: String) {
|
||||
callGetInventory(
|
||||
parkingFrom,
|
||||
parkingTo
|
||||
)
|
||||
ma.hideKeyboard(customDialogList.getEditText())
|
||||
listParkings.clear()
|
||||
customDialogList.dismiss()
|
||||
binding.editMatricula.requestFocus()
|
||||
}
|
||||
|
||||
private fun callGetInventory(parkingFromScan: String, parkingToScan: String) {
|
||||
parkingFrom = parkingFromScan
|
||||
parkingTo = parkingToScan
|
||||
|
@ -373,7 +446,7 @@ class InventaryParkingFragment(
|
|||
)
|
||||
|
||||
binding.editMatricula.hint = getString(R.string.scanShelving)
|
||||
chageListAdapter(listIcons.filter {
|
||||
changeListAdapter(listIcons.filter {
|
||||
it.drawable.constantState?.equals(
|
||||
AppCompatResources.getDrawable(
|
||||
requireContext(),
|
||||
|
@ -396,7 +469,7 @@ class InventaryParkingFragment(
|
|||
try {
|
||||
binding.editMatricula.setText(
|
||||
itemScanValue(
|
||||
binding.editMatricula.text.toString(), "buy", "more"
|
||||
binding.editMatricula.text.toString(), arrayOf("buy"), "more"
|
||||
).toString().uppercase()
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
|
@ -429,7 +502,7 @@ class InventaryParkingFragment(
|
|||
titleWithError = "",
|
||||
isToasted = true
|
||||
)
|
||||
chageListAdapter(listIcons)
|
||||
changeListAdapter(listIcons)
|
||||
adapter!!.setItems(myListInventory.filter { it.shelvingFk.uppercase() == myListInventory[positionShelvingChecking].shelvingFk.uppercase() })
|
||||
positionShelvingChecking = -1
|
||||
positionItemChecking = -1
|
||||
|
@ -449,7 +522,7 @@ class InventaryParkingFragment(
|
|||
)
|
||||
} else {
|
||||
|
||||
chageListAdapter(listIcons)
|
||||
changeListAdapter(listIcons)
|
||||
adapter!!.setItems(myListInventory.filter { it.shelvingFk == myListInventory[positionShelvingChecking].shelvingFk })
|
||||
|
||||
binding.editMatricula.hint = getString(R.string.scanItemForChecking)
|
||||
|
@ -464,7 +537,7 @@ class InventaryParkingFragment(
|
|||
|
||||
viewModel.getIdFromCodeSalix(
|
||||
code = itemScanValue(
|
||||
binding.editMatricula.text.toString(), "buy", "more"
|
||||
binding.editMatricula.text.toString(), arrayOf("buy"), "more"
|
||||
).toString()
|
||||
)
|
||||
|
||||
|
@ -490,7 +563,7 @@ class InventaryParkingFragment(
|
|||
}
|
||||
|
||||
private fun resetChecking() {
|
||||
chageListAdapter(listIcons)
|
||||
changeListAdapter(listIcons)
|
||||
positionShelvingChecking = -1
|
||||
positionItemChecking = -1
|
||||
shelvingSaved = ""
|
||||
|
@ -568,7 +641,7 @@ class InventaryParkingFragment(
|
|||
}
|
||||
|
||||
response.observe(viewLifecycleOwner) {
|
||||
chageListAdapter(listIcons, true)
|
||||
changeListAdapter(listIcons, true)
|
||||
callGetInventory(
|
||||
parkingFrom, parkingTo
|
||||
)
|
||||
|
@ -578,7 +651,7 @@ class InventaryParkingFragment(
|
|||
callGetInventory(
|
||||
parkingFrom, parkingTo
|
||||
)
|
||||
chageListAdapter(listIcons, true)
|
||||
changeListAdapter(listIcons, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -654,4 +727,15 @@ class InventaryParkingFragment(
|
|||
customDialogInput.setFocusText()
|
||||
}
|
||||
|
||||
override fun onBackPressedHandled(): Boolean {
|
||||
|
||||
|
||||
if (shelvingSaved.isBlank()) {
|
||||
ma.onMyBackPressed()
|
||||
return false
|
||||
} else {
|
||||
resetChecking()
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue