feat itemShelvingLog refs #7168

This commit is contained in:
Sergio De la torre 2024-07-31 12:12:18 +02:00
parent c87707a0ca
commit ec6b61b414
5 changed files with 47 additions and 17 deletions

View File

@ -64,7 +64,7 @@ object ConstAndValues {
const val MENUBYDEFAULTSELECTED = "MENUBYDEFAULTSELECTED" const val MENUBYDEFAULTSELECTED = "MENUBYDEFAULTSELECTED"
const val INVENTORYPARKINGTO = "INVENTORYPARKINGTO" const val INVENTORYPARKINGTO = "INVENTORYPARKINGTO"
const val INVENTORYPARKINGFROM = "INVENTORYPARKINGFROM" const val INVENTORYPARKINGFROM = "INVENTORYPARKINGFROM"
const val LIMITRECORDSSHELVINGLOG = 25 const val LIMITRECORDSSHELVINGLOG = 50
const val RESERVATIONMODE = "operatorReservationMode" const val RESERVATIONMODE = "operatorReservationMode"
} }

View File

@ -10,7 +10,7 @@ import es.verdnatura.presentation.view.feature.historicoshelving.model.ItemShelv
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
class ItemShelvingLogAdapter( class ItemShelvingLogAdapter(
private val items: List<ItemShelvingLog>, private var items: List<ItemShelvingLog>,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener private val onPasillerosItemClickListener: OnPasillerosItemClickListener
) : RecyclerView.Adapter<ItemShelvingLogAdapter.ItemHolder>() { ) : RecyclerView.Adapter<ItemShelvingLogAdapter.ItemHolder>() {
@ -39,7 +39,11 @@ class ItemShelvingLogAdapter(
} }
} }
fun addList(list:List<ItemShelvingLog>){
items = list
notifyDataSetChanged()
}
inner class ItemHolder( inner class ItemHolder(
val binding: ItemShelvinglogRowBinding val binding: ItemShelvinglogRowBinding
) : RecyclerView.ViewHolder(binding.root) { ) : RecyclerView.ViewHolder(binding.root) {

View File

@ -1,6 +1,8 @@
package es.verdnatura.presentation.view.feature.historicoshelving.fragment package es.verdnatura.presentation.view.feature.historicoshelving.fragment
import android.content.Context import android.content.Context
import android.os.Handler
import android.os.Looper
import android.view.View import android.view.View
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -23,6 +25,8 @@ class ItemShelvingLogFragment(
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
private var records: Int = LIMITRECORDSSHELVINGLOG private var records: Int = LIMITRECORDSSHELVINGLOG
private var shelving: String = "" private var shelving: String = ""
private var positionScroll = 0
private var positionToReturn = 0
companion object { companion object {
fun newInstance(entryPoint: String) = ItemShelvingLogFragment(entryPoint) fun newInstance(entryPoint: String) = ItemShelvingLogFragment(entryPoint)
@ -37,10 +41,25 @@ class ItemShelvingLogFragment(
customDialog = CustomDialog(requireContext()) customDialog = CustomDialog(requireContext())
setEvents() setEvents()
setToolBar(getString(R.string.itemShelvingLog)) setToolBar(getString(R.string.itemShelvingLog))
setAdapter()
super.init() super.init()
} }
private fun setAdapter() {
binding.itemshelvinglogRecyclerview.layoutManager =
LinearLayoutManager(
requireContext(),
LinearLayoutManager.VERTICAL,
false
)
adapter = ItemShelvingLogAdapter(
listOf(),
onPasillerosItemClickListener = pasillerosItemClickListener!!
)
binding.itemshelvinglogRecyclerview.adapter = adapter
}
override fun onAttach(context: Context) { override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
super.onAttach(context) super.onAttach(context)
@ -51,11 +70,18 @@ class ItemShelvingLogFragment(
} }
private fun setEvents() { private fun setEvents() {
val scrollView = binding.scrollView
scrollView.setOnScrollChangeListener { _, _, scrollY, _, _->
positionScroll = scrollY
}
binding.scanInput.requestFocus() binding.scanInput.requestFocus()
binding.loadMoreButton.setOnClickListener { binding.loadMoreButton.setOnClickListener {
positionToReturn = positionScroll
records += LIMITRECORDSSHELVINGLOG records += LIMITRECORDSSHELVINGLOG
try { try {
viewModel.getIdFromCodeSalix(shelving.toLong().toString()) viewModel.getIdFromCodeSalix(shelving.toLong().toString(), records)
} catch (ex: Exception) { } catch (ex: Exception) {
viewModel.itemShelvingLogGet( viewModel.itemShelvingLogGet(
@ -71,7 +97,7 @@ class ItemShelvingLogFragment(
shelving = binding.scanInput.text.toString() shelving = binding.scanInput.text.toString()
records = LIMITRECORDSSHELVINGLOG records = LIMITRECORDSSHELVINGLOG
try { try {
viewModel.getIdFromCodeSalix(binding.scanInput.toLong().toString()) viewModel.getIdFromCodeSalix(binding.scanInput.toLong().toString(), records)
} catch (ex: Exception) { } catch (ex: Exception) {
viewModel.itemShelvingLogGet( viewModel.itemShelvingLogGet(
shelving, shelving,
@ -103,24 +129,22 @@ class ItemShelvingLogFragment(
customDialog.dismiss() customDialog.dismiss()
}.show() }.show()
} else { } else {
adapter = ItemShelvingLogAdapter(
it.list,
onPasillerosItemClickListener = pasillerosItemClickListener!!
)
//TAREA 7168 //TAREA 7168
if (it.list.size == records) { if (it.list.size == records) {
binding.loadMoreButton.visibility = View.VISIBLE binding.loadMoreButton.visibility = View.VISIBLE
} else { } else {
binding.loadMoreButton.visibility = View.GONE binding.loadMoreButton.visibility = View.GONE
} }
binding.itemshelvinglogRecyclerview.adapter = adapter adapter!!.addList(it.list)
binding.itemshelvinglogRecyclerview.layoutManager =
LinearLayoutManager(
requireContext(),
LinearLayoutManager.VERTICAL,
false
)
setToolBar(getString(R.string.itemShelvingLog) + ":" + itemScan) setToolBar(getString(R.string.itemShelvingLog) + ":" + itemScan)
val handler = Handler(Looper.getMainLooper())
handler.postDelayed({
binding.scrollView.smoothScrollTo(0, positionToReturn)
}, 1000)
} }
} }
} }

View File

@ -42,12 +42,12 @@ class ItemShelvingLogViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun getIdFromCodeSalix(code: String) { fun getIdFromCodeSalix(code: String, records: Int) {
getItemFromBarcodeUseCase.execute (code) getItemFromBarcodeUseCase.execute (code)
.enqueue(object : SalixCallback<Int?>(context) { .enqueue(object : SalixCallback<Int?>(context) {
override fun onSuccess(response: Response<Int?>) { override fun onSuccess(response: Response<Int?>) {
itemShelvingLogGet(response.body()!!.toString()) itemShelvingLogGet(response.body()!!.toString(), records)
} }
}) })

View File

@ -28,6 +28,8 @@ class ItemUbicador(
var packing: Int? = null, var packing: Int? = null,
var grouping: Int? = null, var grouping: Int? = null,
var code: String? = "", var code: String? = "",
var created:String? = null,
var shelvingFk: String? = null,
var id: Int = 0, var id: Int = 0,
var priority: Int = 0, var priority: Int = 0,
var isError: Boolean = false, var isError: Boolean = false,