refs #6413 feat:refactor Ubicador
This commit is contained in:
parent
985a63b9c6
commit
b3cd417673
|
@ -23,6 +23,7 @@ import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||||
import es.verdnatura.presentation.view.feature.sacador.model.Sale
|
import es.verdnatura.presentation.view.feature.sacador.model.Sale
|
||||||
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
|
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
|
||||||
import es.verdnatura.presentation.view.feature.smarttag.model.SmartTag
|
import es.verdnatura.presentation.view.feature.smarttag.model.SmartTag
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
|
||||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
|
||||||
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake
|
import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake
|
||||||
|
|
||||||
|
@ -129,6 +130,9 @@ interface OnAutomaticItemClickListener {
|
||||||
interface OnVisibleClickListener {
|
interface OnVisibleClickListener {
|
||||||
fun onVisibleClickListener(item: ItemUbicadorVO)
|
fun onVisibleClickListener(item: ItemUbicadorVO)
|
||||||
}
|
}
|
||||||
|
interface OnVisibleClickListenerNew {
|
||||||
|
fun onVisibleClickListener(item: ItemUbicador)
|
||||||
|
}
|
||||||
|
|
||||||
interface OnVisibleInventoryClickListener {
|
interface OnVisibleInventoryClickListener {
|
||||||
fun onVisibleInventoryClickListener(item: ItemInventoryParking)
|
fun onVisibleInventoryClickListener(item: ItemInventoryParking)
|
||||||
|
@ -137,7 +141,9 @@ interface OnVisibleInventoryClickListener {
|
||||||
interface OnMoreClickListener {
|
interface OnMoreClickListener {
|
||||||
fun onMoreClickListener(item: ItemUbicadorVO)
|
fun onMoreClickListener(item: ItemUbicadorVO)
|
||||||
}
|
}
|
||||||
|
interface OnMoreClickListenerNew {
|
||||||
|
fun onMoreClickListener(item: ItemUbicador)
|
||||||
|
}
|
||||||
interface OnTruckClickListener {
|
interface OnTruckClickListener {
|
||||||
fun onTruckClickListener(item: ItemExpeditionTruckVO, entryPoint: String)
|
fun onTruckClickListener(item: ItemExpeditionTruckVO, entryPoint: String)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.ubicador.adapter
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.ItemUbicationRowNewBinding
|
||||||
|
import es.verdnatura.presentation.common.OnMoreClickListenerNew
|
||||||
|
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnVisibleClickListenerNew
|
||||||
|
import es.verdnatura.presentation.common.loadUrl
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
|
||||||
|
|
||||||
|
class UbicadorAdapterNew(
|
||||||
|
private val items: List<ItemUbicador>,
|
||||||
|
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
|
||||||
|
private val onVisibleClickListener: OnVisibleClickListenerNew,
|
||||||
|
private val onMoreClickListener: OnMoreClickListenerNew
|
||||||
|
) : RecyclerView.Adapter<UbicadorAdapterNew.ItemHolder>() {
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||||
|
return ItemHolder(
|
||||||
|
ItemUbicationRowNewBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() = items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class ItemHolder(
|
||||||
|
val binding: ItemUbicationRowNewBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
private val res = binding.root.context.resources
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
fun bind(item: ItemUbicador) {
|
||||||
|
binding.apply {
|
||||||
|
this.item = item
|
||||||
|
multiText.text = "${item.stickers}x${item.packing}"
|
||||||
|
|
||||||
|
if (!item.url.isNullOrBlank()) {
|
||||||
|
imgItem.loadUrl(item.url+"/catalog/200x200/"+item.item)
|
||||||
|
} else {
|
||||||
|
imgItem.loadUrl("https://cdn.verdnatura.es/image/catalog/200x200/" + item.item)
|
||||||
|
}
|
||||||
|
imgItem.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||||
|
PasillerosItemVO(
|
||||||
|
title = res.getString(
|
||||||
|
R.string.itemSearch
|
||||||
|
)
|
||||||
|
), item.item.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
layerVisible.setOnClickListener {
|
||||||
|
onVisibleClickListener.onVisibleClickListener(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.visible == 0) {
|
||||||
|
visibleText.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
visibleText.context,
|
||||||
|
R.color.verdnatura_brown_grey
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
visibleText.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
visibleText.context,
|
||||||
|
R.color.verdnatura_pumpkin_orange
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
moreImg.setOnClickListener {
|
||||||
|
onMoreClickListener.onMoreClickListener(item)
|
||||||
|
}
|
||||||
|
namelayout.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(
|
||||||
|
PasillerosItemVO(
|
||||||
|
title = res.getString(R.string.itemSearch)
|
||||||
|
), item.item.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.isChecked != null) {
|
||||||
|
|
||||||
|
when (item.isChecked!!.toInt()) {
|
||||||
|
0 -> itemRowLayout.setBackgroundColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
visibleText.context,
|
||||||
|
R.color.verdnatura_red_salix
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
in 1..Int.MAX_VALUE ->
|
||||||
|
if (item.visible == 0) {
|
||||||
|
itemRowLayout.setBackgroundColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
visibleText.context,
|
||||||
|
R.color.verdnatura_dark_sky_blue
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
itemRowLayout.setBackgroundColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
visibleText.context,
|
||||||
|
R.color.verdnatura_dark_green_verdnatura
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
itemRowLayout.setBackgroundColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
visibleText.context,
|
||||||
|
R.color.verdnatura_black_5
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,780 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.ubicador.fragment
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.os.Build
|
||||||
|
import android.text.InputType
|
||||||
|
import android.text.TextWatcher
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
|
import android.view.View.GONE
|
||||||
|
import android.view.View.VISIBLE
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentUbicadorBinding
|
||||||
|
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||||
|
import es.verdnatura.domain.notNull
|
||||||
|
import es.verdnatura.domain.toInt
|
||||||
|
import es.verdnatura.domain.toast
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.*
|
||||||
|
import es.verdnatura.presentation.view.component.*
|
||||||
|
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
|
||||||
|
import kotlin.math.roundToLong
|
||||||
|
|
||||||
|
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||||
|
class UbicadorFragmentNew(
|
||||||
|
var shelvingFk: String = "", var isAutoSelf: Boolean
|
||||||
|
) : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel>(
|
||||||
|
UbicadorViewModel::class
|
||||||
|
) {
|
||||||
|
|
||||||
|
private var adapter: UbicadorAdapterNew? = null
|
||||||
|
private lateinit var customDialogInput: CustomDialogInput
|
||||||
|
private lateinit var customDialogUbicador: CustomDialogUbicadorNew
|
||||||
|
private lateinit var customDialogTwoButtons: CustomDialogTwoButtons
|
||||||
|
private var listItems: MutableList<ItemUbicador> = mutableListOf()
|
||||||
|
private var listLocalItems: ArrayList<ItemUbicador> = ArrayList()
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private var parking: String = ""
|
||||||
|
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||||
|
private var isShelvinLogfromMainScreen = false
|
||||||
|
private var modeCheckUbication = false
|
||||||
|
private var itemScannedScreen: Long = 0
|
||||||
|
var isBack = false
|
||||||
|
var listIcons: ArrayList<ImageView> = ArrayList()
|
||||||
|
private lateinit var textWatcher: TextWatcher
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(entryPoint: String, autoSelf: Boolean = false) =
|
||||||
|
UbicadorFragmentNew(entryPoint, autoSelf)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_ubicador
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
isBack = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||||
|
super.onAttach(context)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
|
override fun init() {
|
||||||
|
|
||||||
|
setDialogs()
|
||||||
|
setEvents()
|
||||||
|
setToolBar()
|
||||||
|
|
||||||
|
//setNewIcons()
|
||||||
|
ma.hideBottomNavigation(GONE)
|
||||||
|
|
||||||
|
if (!shelvingFk.isNullOrEmpty()) {
|
||||||
|
isShelvinLogfromMainScreen = false
|
||||||
|
setIconsActions(true)
|
||||||
|
setIcons()
|
||||||
|
binding.mainToolbar.toolbarTitle.text = shelvingFk
|
||||||
|
viewModel.itemShelvingListNew(shelvingFk)
|
||||||
|
binding.mainToolbar.switchButton.visibility = VISIBLE
|
||||||
|
} else {
|
||||||
|
isShelvinLogfromMainScreen = true
|
||||||
|
setIconsActions(false)
|
||||||
|
}
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setIconsActions(showIcons: Boolean) {
|
||||||
|
|
||||||
|
binding.layoutIconsActions.visibility = if (showIcons) {
|
||||||
|
VISIBLE
|
||||||
|
} else {
|
||||||
|
GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
when (item.itemId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setDialogs() {
|
||||||
|
customDialogInput = CustomDialogInput(requireContext())
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setToolBar() {
|
||||||
|
binding.mainToolbar.switchButton.visibility = GONE
|
||||||
|
binding.mainToolbar.toolbarTitle.text = if (!isAutoSelf) {
|
||||||
|
getString(R.string.locator)
|
||||||
|
} else {
|
||||||
|
getString(R.string.selfConsumption)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
|
private fun setIcons() {
|
||||||
|
|
||||||
|
listIcons.clear()
|
||||||
|
val iconAdd = ImageView(context)
|
||||||
|
iconAdd.setImageResource(R.drawable.ic_add_black_24dp)
|
||||||
|
val iconReload = ImageView(context)
|
||||||
|
iconReload.setImageResource(R.drawable.ic_autorenew_black_24dp)
|
||||||
|
val iconReset = ImageView(context)
|
||||||
|
iconReset.setImageResource(R.drawable.ic_remove_checks)
|
||||||
|
|
||||||
|
binding.mainToolbar.switchButton.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||||
|
if (binding.mainToolbar.toolbarTitle.text == getString(R.string.titleUbicator)) {
|
||||||
|
getString(R.string.scanShelving).toast(requireContext())
|
||||||
|
binding.mainToolbar.switchButton.isChecked = false
|
||||||
|
} else {
|
||||||
|
modeCheckUbication = isChecked
|
||||||
|
binding.mainToolbar.toolbarIcons.adapter!!.notifyDataSetChanged()
|
||||||
|
binding.mainToolbar.switchButton.tooltipText =
|
||||||
|
if (isChecked) getString(R.string.activateModoChecking) else getString(R.string.allowCheckingMode)
|
||||||
|
binding.textinputlayoutMatricula.hint =
|
||||||
|
if (isChecked) getString(R.string.scanItem) else {
|
||||||
|
getString(R.string.scanPlate)
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!isChecked) {
|
||||||
|
listLocalItems.clear()
|
||||||
|
listIcons.remove(iconReset)
|
||||||
|
} else {
|
||||||
|
listIcons.add(iconReset)
|
||||||
|
}
|
||||||
|
binding.mainToolbar.toolbarIcons.adapter!!.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
iconReload.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
|
||||||
|
iconAdd.tooltipText = getString(R.string.addItemShelving)
|
||||||
|
iconReset.tooltipText = getTooltip(R.drawable.ic_remove_checks)
|
||||||
|
|
||||||
|
}
|
||||||
|
listIcons.add(iconAdd)
|
||||||
|
listIcons.add(iconReload)
|
||||||
|
|
||||||
|
binding.mainToolbar.toolbarIcons.adapter =
|
||||||
|
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
|
||||||
|
override fun onOptionsItemSelected(item: Drawable) {
|
||||||
|
|
||||||
|
when (item) {
|
||||||
|
iconAdd.drawable -> showAddItemNew(
|
||||||
|
isEditItem = false, null
|
||||||
|
)
|
||||||
|
|
||||||
|
iconReload.drawable -> {
|
||||||
|
|
||||||
|
if (!shelvingFk.isNullOrEmpty()) {
|
||||||
|
binding.editPrioridad.setText("")
|
||||||
|
viewModel.itemShelvingListNew(
|
||||||
|
shelvingFk
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
getString(R.string.scanShelving).toast(
|
||||||
|
requireActivity(), Toast.LENGTH_SHORT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iconReset.drawable -> {
|
||||||
|
if (!shelvingFk.isNullOrBlank()) {
|
||||||
|
customDialog.setTitle(getString(R.string.checkItemShelvingDescrip))
|
||||||
|
.setDescription(getString(R.string.checkItemShelving))
|
||||||
|
.setOkButton(getString(R.string.ok)) {
|
||||||
|
viewModel.itemShelvingDeleteChecked(shelvingFk)
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
|
customDialog.dismiss()
|
||||||
|
|
||||||
|
}.show()
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
getString(R.string.scanPlate),
|
||||||
|
isError = true,
|
||||||
|
isPlayed = true,
|
||||||
|
isToasted = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
binding.mainToolbar.toolbarIcons.layoutManager =
|
||||||
|
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
private fun setEvents() {
|
||||||
|
binding.mainToolbar.backButton.setOnClickListener {
|
||||||
|
requireActivity().onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
setTooltips()
|
||||||
|
binding.editMatricula.requestFocus()
|
||||||
|
binding.editMatricula.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
if (!binding.editMatricula.text.toString().isNullOrEmpty()) {
|
||||||
|
setIconsActions(true)
|
||||||
|
setIcons()
|
||||||
|
if (!modeCheckUbication || (modeCheckUbication && binding.editMatricula.text.toString().length == 3 && !binding.editMatricula.text!![0].isDigit())) {
|
||||||
|
binding.mainToolbar.toolbarTitle.text =
|
||||||
|
binding.editMatricula.text.toString()
|
||||||
|
shelvingFk = binding.editMatricula.text.toString()
|
||||||
|
parking = ""
|
||||||
|
binding.editPrioridad.setText("")
|
||||||
|
isShelvinLogfromMainScreen = true
|
||||||
|
viewModel.itemShelvingListNew(
|
||||||
|
binding.editMatricula.text.toString()
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
viewModel.getIdFromCode(
|
||||||
|
code = itemScanValue(
|
||||||
|
binding.editMatricula.text.toString(), "buy", "more"
|
||||||
|
).toString()
|
||||||
|
)
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
ma.messageWithSound(ex.message.toString(), true, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.mainToolbar.switchButton.visibility = VISIBLE
|
||||||
|
|
||||||
|
binding.editMatricula.setText("")
|
||||||
|
ma.hideKeyboard(binding.editMatricula)
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
|
||||||
|
return@setOnEditorActionListener false
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.editPrioridad.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
if (!binding.editPrioridad.text.toString().isNullOrEmpty()) {
|
||||||
|
viewModel.shelvingPriorityUpdate(
|
||||||
|
binding.editPrioridad.toInt(), shelvingFk
|
||||||
|
)
|
||||||
|
isBack = false
|
||||||
|
|
||||||
|
}
|
||||||
|
ma.hideKeyboard(binding.editPrioridad)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.editMatricula.requestFocus()
|
||||||
|
return@setOnEditorActionListener false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
binding.automaticImg.setOnClickListener {
|
||||||
|
if (!shelvingFk.isNullOrEmpty())
|
||||||
|
|
||||||
|
ma.onPasillerosItemClickListener(
|
||||||
|
PasillerosItemVO(title = getString(R.string.titleAuto)), entryPoint = shelvingFk
|
||||||
|
)
|
||||||
|
else getString(R.string.scanShelving).toast(
|
||||||
|
requireActivity(), Toast.LENGTH_SHORT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.parkingImg.setOnClickListener {
|
||||||
|
if (!shelvingFk.isNullOrBlank()) {
|
||||||
|
customDialogInput.setTitle(getString(R.string.parkingShelving)).setValue("")
|
||||||
|
.setOkButton(
|
||||||
|
getString(
|
||||||
|
R.string.parking
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
customDialogActionParking()
|
||||||
|
|
||||||
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.show()
|
||||||
|
} else {
|
||||||
|
|
||||||
|
getString(R.string.errorShelving).toast(
|
||||||
|
requireContext()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
customDialogInput.getEditText().requestFocus()
|
||||||
|
ma.hideKeyboard(customDialogInput.getEditText())
|
||||||
|
|
||||||
|
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
customDialogActionParking()
|
||||||
|
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.editImg.setOnClickListener {
|
||||||
|
if (!shelvingFk.isNullOrBlank()) {
|
||||||
|
customDialogInput.setTitle(getString(R.string.changeShelving)).setValue("")
|
||||||
|
.setOkButton(getString(R.string.save)) {
|
||||||
|
if (!customDialogInput.getValue().isNullOrBlank()) {
|
||||||
|
customDialogActionChange()
|
||||||
|
} else {
|
||||||
|
getString(R.string.errorShelving).toast(
|
||||||
|
requireContext()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.show()
|
||||||
|
} else {
|
||||||
|
getString(R.string.errorShelving).toast(
|
||||||
|
requireContext()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
customDialogInput.getEditText().requestFocus()
|
||||||
|
ma.hideKeyboard(customDialogInput.getEditText())
|
||||||
|
|
||||||
|
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
customDialogActionChange()
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.deleteImg.setOnClickListener {
|
||||||
|
if (!shelvingFk.isNullOrBlank()) {
|
||||||
|
customDialog.setTitle(getString(R.string.empty))
|
||||||
|
.setDescription(getString(R.string.operationNoReturn))
|
||||||
|
.setOkButton(getString(R.string.empty)) {
|
||||||
|
|
||||||
|
viewModel.clearShelvingList(
|
||||||
|
shelvingFk
|
||||||
|
)
|
||||||
|
listItems.forEach {
|
||||||
|
it.stickers = 0
|
||||||
|
it.visible = 0
|
||||||
|
}
|
||||||
|
if (adapter != null) {
|
||||||
|
adapter!!.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
customDialog.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
customDialog.setKoButton(getString(R.string.cancel)) {
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
} else {
|
||||||
|
getString(R.string.errorShelving).toast(
|
||||||
|
requireContext()
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun customDialogActionParking() {
|
||||||
|
viewModel.setParking(
|
||||||
|
shelvingFk, customDialogInput.getValue()
|
||||||
|
)
|
||||||
|
parking = customDialogInput.getValue()
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun customDialogActionChange() {
|
||||||
|
viewModel.shelvingChangeSalix(
|
||||||
|
shelvingFk, customDialogInput.getValue()
|
||||||
|
)
|
||||||
|
shelvingFk = customDialogInput.getValue()
|
||||||
|
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkUbications(itemScanned: Long) {
|
||||||
|
itemScannedScreen = itemScanned
|
||||||
|
val listInt: ArrayList<Long> = ArrayList()
|
||||||
|
|
||||||
|
if (listItems.filter { it.item == itemScanned }.isEmpty()) {
|
||||||
|
listInt.add(itemScanned)
|
||||||
|
} else {
|
||||||
|
listItems.sortedBy { it.isChecked }.forEachIndexed { index, item ->
|
||||||
|
if (item.item == itemScanned) {
|
||||||
|
item.checked = true
|
||||||
|
listInt.add(item.item)
|
||||||
|
ma.messageWithSound("", false, true, "", false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
viewModel.itemShelvingAddList(
|
||||||
|
shelvingFk,
|
||||||
|
"" + listInt + "",
|
||||||
|
TRUE,
|
||||||
|
mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
|
||||||
|
)
|
||||||
|
|
||||||
|
adapter!!.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setTooltips() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
binding.editImg.tooltipText = getTooltip(R.drawable.ic_mode_edit_black_24dp)
|
||||||
|
binding.deleteImg.tooltipText = getTooltip(R.drawable.ic_delete_forever_black_24dp)
|
||||||
|
binding.editPrioridad.tooltipText = getString(R.string.changePriority)
|
||||||
|
binding.parkingImg.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
|
||||||
|
binding.automaticImg.tooltipText = getTooltip(R.drawable.ic_flash_auto_black_24dp)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
override fun observeViewModel() {
|
||||||
|
|
||||||
|
with(viewModel) {
|
||||||
|
|
||||||
|
loadShelvingListNew.observe(viewLifecycleOwner, Observer { event ->
|
||||||
|
event.getContentIfNotHandled().notNull { it ->
|
||||||
|
|
||||||
|
if (isShelvinLogfromMainScreen) {
|
||||||
|
viewModel.shelvinLog_add(shelvingFk)
|
||||||
|
}
|
||||||
|
listItems = ArrayList()
|
||||||
|
val totalStickers = it.list.sumOf { item -> item.stickers }
|
||||||
|
parking = it.list.firstOrNull { item -> item.code != null }?.code ?: ""
|
||||||
|
listItems.addAll(it.list)
|
||||||
|
|
||||||
|
binding.mainToolbar.toolbarTitle.text =
|
||||||
|
shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString(
|
||||||
|
R.string.label
|
||||||
|
) + totalStickers
|
||||||
|
if (listItems.isNotEmpty()) binding.editPrioridad.setText(it.list[0].priority.toString())
|
||||||
|
|
||||||
|
if (!binding.mainToolbar.switchButton.isChecked && listItems.isNotEmpty()) {
|
||||||
|
listItems = listItems.asReversed()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listItems.isNotEmpty()) {
|
||||||
|
binding.deleteImg.visibility = VISIBLE
|
||||||
|
|
||||||
|
} else {
|
||||||
|
binding.deleteImg.visibility = View.INVISIBLE
|
||||||
|
}
|
||||||
|
setAdapter(listItems)
|
||||||
|
setPosition()
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
loadAddList.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
viewModel.itemShelvingListNew(shelvingFk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.observe(viewLifecycleOwner, Observer {
|
||||||
|
viewModel.itemShelvingListNew(shelvingFk)
|
||||||
|
})
|
||||||
|
responseLog.observe(viewLifecycleOwner, Observer {
|
||||||
|
|
||||||
|
if (!it.isError) {
|
||||||
|
isShelvinLogfromMainScreen = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
loadResponseCode.observe(viewLifecycleOwner) { event ->
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
if (it.isError) {
|
||||||
|
ma.messageWithSound(it.errorMessage, it.isError, true)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
checkUbications(it.response.toDouble().roundToLong())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
responseMake.observe(viewLifecycleOwner, Observer {
|
||||||
|
|
||||||
|
if (!shelvingFk.isNullOrEmpty()) {
|
||||||
|
binding.mainToolbar.toolbarTitle.text = shelvingFk
|
||||||
|
viewModel.itemShelvingListNew(
|
||||||
|
shelvingFk
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setPosition() {
|
||||||
|
if (modeCheckUbication) {
|
||||||
|
listItems.sortedBy { it.isChecked }.forEachIndexed { index, item ->
|
||||||
|
if (item.item == itemScannedScreen) {
|
||||||
|
binding.locationRecyclerview.scrollToPosition(
|
||||||
|
index
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
(binding.locationRecyclerview.layoutManager as LinearLayoutManager).scrollToPosition(
|
||||||
|
0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setAdapter(listItems: MutableList<ItemUbicador>) {
|
||||||
|
adapter = UbicadorAdapterNew(listItems.sortedBy { it.isChecked },
|
||||||
|
onPasillerosItemClickListener = pasillerosItemClickListener!!,
|
||||||
|
onVisibleClickListener = object : OnVisibleClickListenerNew {
|
||||||
|
override fun onVisibleClickListener(item: ItemUbicador) {
|
||||||
|
|
||||||
|
if (!isAutoSelf) {
|
||||||
|
showAddItemNew(
|
||||||
|
itemUbicador = item, isEditItem = true
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
showAutoSelfConsumption(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
onMoreClickListener = object : OnMoreClickListenerNew {
|
||||||
|
override fun onMoreClickListener(item: ItemUbicador) {
|
||||||
|
showMoreOptions(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
binding.locationRecyclerview.adapter = adapter
|
||||||
|
binding.locationRecyclerview.layoutManager = LinearLayoutManager(
|
||||||
|
requireContext(), LinearLayoutManager.VERTICAL, false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showAutoSelfConsumption(item: ItemUbicador) {
|
||||||
|
|
||||||
|
customDialogInput.setInputText(InputType.TYPE_CLASS_NUMBER)
|
||||||
|
customDialogInput.setTitle(getString(R.string.selfConsumption))
|
||||||
|
customDialogInput.setDescription(getString(R.string.quantityTake)).setValue("")
|
||||||
|
.setOkButton(getString(R.string.take)) {
|
||||||
|
try {
|
||||||
|
if (customDialogInput.getValue().toInt() > 0) {
|
||||||
|
val quantity =
|
||||||
|
if (item.visible - customDialogInput.getValue().toInt() > 0) {
|
||||||
|
item.visible - customDialogInput.getValue().toInt()
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
viewModel.itemShelvingSelfConsumption(
|
||||||
|
shelvingFk, item.item.toInt(), quantity
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
throw Exception("")
|
||||||
|
}
|
||||||
|
} catch (err: Exception) {
|
||||||
|
(getString(R.string.errorQuantity).toast(requireContext()))
|
||||||
|
}
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
|
||||||
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.show()
|
||||||
|
customDialogInput.setFocusText()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showAddItemNew(
|
||||||
|
isEditItem: Boolean,
|
||||||
|
itemUbicador: ItemUbicador?,
|
||||||
|
) {
|
||||||
|
customDialogUbicador = CustomDialogUbicadorNew(requireContext())
|
||||||
|
|
||||||
|
|
||||||
|
if (isEditItem) {
|
||||||
|
customDialogUbicador.setTitle(getString(R.string.editItem) + itemUbicador!!.item)
|
||||||
|
.setItemValue(itemUbicador!!.item.toString())
|
||||||
|
.setPackingValue(itemUbicador.packing.toString())
|
||||||
|
.setVisibleValue(itemUbicador.visible.toString())
|
||||||
|
.setEtiquetaValue((itemUbicador.visible / (itemUbicador.packing ?: 0)).toString())
|
||||||
|
.setUnits(
|
||||||
|
if (itemUbicador.stickers != 0) {
|
||||||
|
(itemUbicador.visible % itemUbicador.stickers).toString()
|
||||||
|
} else {
|
||||||
|
"0"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.setOkButton(getString(R.string.save)) {
|
||||||
|
setShowAddItemAction(itemUbicador)
|
||||||
|
}.setKoButton(getString(R.string.close)) {
|
||||||
|
customDialogUbicador.dismiss()
|
||||||
|
}.show()
|
||||||
|
} else {
|
||||||
|
customDialogUbicador.setTitle(getString(R.string.newItem))
|
||||||
|
.setOkButton(getString(R.string.save)) {
|
||||||
|
setShowAddItemAction(null)
|
||||||
|
}.setKoButton(getString(R.string.close)) {
|
||||||
|
customDialogUbicador.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
setWatcher()
|
||||||
|
customDialogUbicador.getEditItem().requestFocus()
|
||||||
|
ma.hideKeyboard(customDialogUbicador.getEditItem())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setShowAddItemAction(itemUbicador: ItemUbicador?) {
|
||||||
|
if (customDialogUbicador.getItemValue()
|
||||||
|
.isNullOrEmpty() || customDialogUbicador.getPackingValue().isNullOrBlank()
|
||||||
|
) {
|
||||||
|
"Los campos item y packing son obligatorios".toast(context)
|
||||||
|
} else {
|
||||||
|
saveItemCall(customDialogUbicador, itemUbicador)
|
||||||
|
customDialogUbicador.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun saveItemCall(
|
||||||
|
customDialogUbicador: CustomDialogUbicadorNew,
|
||||||
|
itemUbicador: ItemUbicador?,
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (itemUbicador?.id == null) {
|
||||||
|
viewModel.itemShelvingAdd(
|
||||||
|
shelving = shelvingFk,
|
||||||
|
item = customDialogUbicador.getItemValue().toLong()!!,
|
||||||
|
quantity = customDialogUbicador.getVisibleValue().toIntOrNull()!!,
|
||||||
|
packing = customDialogUbicador.getPackingValue().toIntOrNull(),
|
||||||
|
warehouse = mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK),
|
||||||
|
grouping = null
|
||||||
|
)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
viewModel.itemShelvingMakeEdit(
|
||||||
|
customDialogUbicador.getVisibleValue().toIntOrNull()!!,
|
||||||
|
customDialogUbicador.getPackingValue().toInt(),
|
||||||
|
itemUbicador?.id!!,
|
||||||
|
itemUbicador?.grouping
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setWatcher() {
|
||||||
|
customDialogUbicador.addTextWatcher(customDialogUbicador.getPackingItem()) { s ->
|
||||||
|
|
||||||
|
setValueVisible()
|
||||||
|
}
|
||||||
|
|
||||||
|
customDialogUbicador.addTextWatcher(customDialogUbicador.getEtiquetaItem()) { s ->
|
||||||
|
|
||||||
|
setValueVisible()
|
||||||
|
}
|
||||||
|
|
||||||
|
customDialogUbicador.addTextWatcher(customDialogUbicador.getUnitsItem()) { s ->
|
||||||
|
|
||||||
|
setValueVisible()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setValueVisible() {
|
||||||
|
customDialogUbicador.setVisibleValue("")
|
||||||
|
customDialogUbicador.setVisibleValue(
|
||||||
|
(((customDialogUbicador.getEtiquetaValue().toIntOrNull()
|
||||||
|
?: 0) * (customDialogUbicador.getPackingValue().toIntOrNull()
|
||||||
|
?: 0)) + (customDialogUbicador.getUnitsValue().toIntOrNull() ?: 0)).toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showMoreOptions(item: ItemUbicador) {
|
||||||
|
customDialogTwoButtons.setTitle(item.item.toString())
|
||||||
|
.setDescription(getString(R.string.selectAction))
|
||||||
|
.setOkButton(getString(R.string.transfer)) {
|
||||||
|
customDialogInput.setTitle(getString(R.string.shelvingNew))
|
||||||
|
.setDescription(getString(R.string.selectDestiny) + item.item).setValue("")
|
||||||
|
.setOkButton(getString(R.string.transfer)) {
|
||||||
|
customDialogInputAction(item)
|
||||||
|
|
||||||
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.show()
|
||||||
|
customDialogInput.getEditText().requestFocus()
|
||||||
|
ma.hideKeyboard(customDialogInput.getEditText())
|
||||||
|
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
customDialogInputAction(item)
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
customDialogTwoButtons.dismiss()
|
||||||
|
}.setOkButtonTwo(getString(R.string.delete)) {
|
||||||
|
customDialog.setTitle(getString(R.string.confirm)).setDescription(
|
||||||
|
if (!isAutoSelf) {
|
||||||
|
getString(R.string.itemDeleteConfirm) + item.item + "?"
|
||||||
|
} else {
|
||||||
|
getString(R.string.deleteQuantity) + item.item
|
||||||
|
}
|
||||||
|
).setOkButton(getString(R.string.delete)) {
|
||||||
|
if (!isAutoSelf) {
|
||||||
|
listItems.remove(item)
|
||||||
|
adapter!!.notifyDataSetChanged()
|
||||||
|
viewModel.itemShelvingDelete(
|
||||||
|
item.id
|
||||||
|
)
|
||||||
|
customDialogTwoButtons.dismiss()
|
||||||
|
customDialog.dismiss()
|
||||||
|
} else {
|
||||||
|
viewModel.itemShelvingSelfConsumption(
|
||||||
|
shelvingFk, item.item.toInt(), 0
|
||||||
|
)
|
||||||
|
customDialog.dismiss()
|
||||||
|
customDialogTwoButtons.dismiss()
|
||||||
|
}
|
||||||
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
|
customDialog.dismiss()
|
||||||
|
customDialogTwoButtons.dismiss()
|
||||||
|
}.show()
|
||||||
|
|
||||||
|
}.setKoButton(getString(R.string.cancel)) {
|
||||||
|
customDialogTwoButtons.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun customDialogInputAction(item: ItemUbicador) {
|
||||||
|
if (customDialogInput.getValue().isNotEmpty()) {
|
||||||
|
viewModel.itemShelvingTransfer(
|
||||||
|
item.id, customDialogInput.getValue()
|
||||||
|
)
|
||||||
|
listItems.remove(item)
|
||||||
|
adapter!!.notifyDataSetChanged()
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
} else {
|
||||||
|
getString(R.string.wagonIncorrect).toast(requireContext())
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,7 @@ package es.verdnatura.presentation.view.feature.ubicador.fragment
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.Transformations
|
import androidx.lifecycle.map
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import es.verdnatura.R
|
import es.verdnatura.R
|
||||||
import es.verdnatura.domain.SalixCallback
|
import es.verdnatura.domain.SalixCallback
|
||||||
|
@ -17,6 +17,8 @@ import es.verdnatura.presentation.common.ItemShelvingSalix
|
||||||
import es.verdnatura.presentation.common.ResponseItemVO
|
import es.verdnatura.presentation.common.ResponseItemVO
|
||||||
import es.verdnatura.presentation.view.feature.reubication.model.Reubication
|
import es.verdnatura.presentation.view.feature.reubication.model.Reubication
|
||||||
import es.verdnatura.presentation.view.feature.reubication.model.ReubicationList
|
import es.verdnatura.presentation.view.feature.reubication.model.ReubicationList
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListNew
|
||||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO
|
||||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
|
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
|
@ -38,21 +40,30 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
val responseMake: LiveData<ResponseItemVO>
|
val responseMake: LiveData<ResponseItemVO>
|
||||||
get() = _responseMake
|
get() = _responseMake
|
||||||
|
|
||||||
val loadShelvingList = Transformations.map(_shelvingList) { Event(it) }
|
//val loadShelvingList = Transformations.map(_shelvingList) { Event(it) }
|
||||||
|
val loadShelvingList: LiveData<Event<ItemUbicadorListVO>> = _shelvingList.map { Event(it) }
|
||||||
|
|
||||||
|
private val _shelvingListNew by lazy { MutableLiveData<ItemUbicadorListNew>() }
|
||||||
|
val loadShelvingListNew: LiveData<Event<ItemUbicadorListNew>> =
|
||||||
|
_shelvingListNew.map { Event(it) }
|
||||||
|
|
||||||
private val _reubicationList by lazy { MutableLiveData<ReubicationList>() }
|
private val _reubicationList by lazy { MutableLiveData<ReubicationList>() }
|
||||||
val loadReubicationList = Transformations.map(_reubicationList) { Event(it) }
|
|
||||||
|
//val loadReubicationList = Transformations.map(_reubicationList) { Event(it) }
|
||||||
|
val loadReubicationList: LiveData<Event<ReubicationList>> = _reubicationList.map { Event(it) }
|
||||||
|
|
||||||
private val _responseCode by lazy { MutableLiveData<ResponseItemVO>() }
|
private val _responseCode by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
val responseCode: LiveData<ResponseItemVO>
|
val responseCode: LiveData<ResponseItemVO>
|
||||||
get() = _responseCode
|
get() = _responseCode
|
||||||
|
|
||||||
val loadResponseCode = Transformations.map(_responseCode) { Event(it) }
|
//val loadResponseCode = Transformations.map(_responseCode) { Event(it) }
|
||||||
|
val loadResponseCode: LiveData<Event<ResponseItemVO>> = _responseCode.map { Event(it) }
|
||||||
|
|
||||||
private val _responseAddList by lazy { MutableLiveData<ResponseItemVO>() }
|
private val _responseAddList by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
val responseAddList: LiveData<ResponseItemVO> = _responseAddList
|
val responseAddList: LiveData<ResponseItemVO> = _responseAddList
|
||||||
|
|
||||||
val loadAddList = Transformations.map(_responseAddList) { Event(it) }
|
//val loadAddList = Transformations.map(_responseAddList) { Event(it) }
|
||||||
|
val loadAddList: LiveData<Event<ResponseItemVO>> = _responseAddList.map { Event(it) }
|
||||||
|
|
||||||
private val _responseLog by lazy { MutableLiveData<ResponseItemVO>() }
|
private val _responseLog by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
val responseLog: LiveData<ResponseItemVO>
|
val responseLog: LiveData<ResponseItemVO>
|
||||||
|
@ -86,6 +97,36 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun itemShelvingListNew(
|
||||||
|
vShelvingFk: String
|
||||||
|
) {
|
||||||
|
salix.itemShelvingListNew(params = listOf(vShelvingFk.uppercase()).formatWithQuotes())
|
||||||
|
.enqueue(
|
||||||
|
object : SalixCallback<List<ItemUbicador>>(context) {
|
||||||
|
override fun onSuccess(response: Response<List<ItemUbicador>>) {
|
||||||
|
|
||||||
|
_shelvingListNew.value = response.body()?.let { ItemUbicadorListNew(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(t: Throwable) {
|
||||||
|
val listError: ArrayList<ItemUbicador> = ArrayList()
|
||||||
|
listError.add(
|
||||||
|
ItemUbicador(
|
||||||
|
0,
|
||||||
|
isError = true,
|
||||||
|
errorMessage = getMessageFromAllResponse(
|
||||||
|
nameofFunction(this),
|
||||||
|
t.message!!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
_shelvingListNew.value = ItemUbicadorListNew(listError)
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun shelvingPriorityUpdate(
|
fun shelvingPriorityUpdate(
|
||||||
priority: Int, shelving: String
|
priority: Int, shelving: String
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue